问题
I am new to openERP. I am working on changing the color in tree view for those record whose due_date is less then Today. Those record should be in red color.
I am not able to get the current date as filter in tree view.
xml what I need but not working:
<tree colors="blue:Due_date < Today()" string="Invoice">
<field name="Due_date" />
<field name="date_invoice"/>
<field name="state"/>
</tree>
Working code
<tree colors="blue:state == 'open'" string="Invoice">
<field name="partner_id" groups="base.group_user"/>
<field name="date_invoice"/>
<field name="state"/>
</tree>
I tried with
context_today()
and
datetime.datetime.now()
Nothing work.
Please help me on this.
回答1:
In .xml side <, >, <=, >=
is not supported. So we need to use <, >, <= and >=
This will work, try this,
<tree colors="blue:due_date < current_date;" string="Invoice">
<field name="Due_date" />
<field name="date_invoice"/>
<field name="state"/>
</tree>
回答2:
This will work, try this:
<tree colors="red:due_date < datetime.datetime.combine(context_today(), datetime.time(23,59,59));" string="Invoice"></tree>
来源:https://stackoverflow.com/questions/25699625/how-to-color-a-field-in-tree-view-with-today-as-filter