Search code examples
pythonxmlodooodoo-8

How I can get current date in xml in odoo?


I am adding group by filter of past due in accounting tab in odoo. And want to get context due_date < current date, but i am not getting current date anywhere, I don't know how i can get it, anybody can tell me that how to get current date in odoo?

here is my group by filter

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

and here is my other code in which i did it with computed field but don't how i can get current date

@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')

Solution

  • <xpath expr="//filter[@string='Due Month']" position="after
       <filter string="Past Due" name="past_due_filter" domain="[('date_due','&lt;',current_date)]" />
    
    </xpath>