我如何在odoo中获取xml中的当前日期?

问题描述 投票:3回答:2

我在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')
python xml openerp odoo-8
2个回答
3
投票
<xpath expr="//filter[@string='Due Month']" position="after
   <filter string="Past Due" name="past_due_filter" domain="[('date_due','&lt;',current_date)]" />

</xpath>

2
投票

您可以使用“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'))]"/>
© www.soinside.com 2019 - 2024. All rights reserved.