簡體   English   中英

如何在odoo中獲取xml中的當前日期?

[英]How I can get current date in xml in odoo?

我在odoo的“會計”選項卡中按過期過濾器添加分組。 並且想要獲取上下文Due_date <當前日期 ,但是我沒有在任何地方獲取當前日期,我不知道如何獲取它,有人可以告訴我如何在odoo中獲取當前日期嗎?

這是我的篩選條件

 <xpath expr="//filter[@string='Due Month']" position="after <filter string="Past Due" context="{'group_by':'date_due < current date'}"/> </xpath> 

這是我在其他代碼中使用計算字段完成的代碼,但沒有獲取當前日期的方法

@api.depends('date_due')
@api.multi
def _compute_due_date(self):
    for record in self:
        record.past_due = record.date_due < record.date.today().strftime('%Y-%m-%d')
<xpath expr="//filter[@string='Due Month']" position="after
   <filter string="Past Due" name="past_due_filter" domain="[('date_due','&lt;',current_date)]" />

</xpath>

您可以使用“ context_today”或time模塊,例如:

 <filter name="today" string="Today" domain="[('date','=',time.strftime('%%Y-%%m-%%d'))]"/>

 <filter name="last_24h" string="Last 24h" domain="[('start_date','&gt;', (context_today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d'))]"/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM