How to color a field in tree view with today as fi

2019-06-11 17:13发布

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.

2条回答
老娘就宠你
2楼-- · 2019-06-11 17:40

This will work, try this:

<tree colors="red:due_date &lt; datetime.datetime.combine(context_today(), datetime.time(23,59,59));" string="Invoice"></tree>
查看更多
走好不送
3楼-- · 2019-06-11 17:43

In .xml side <, >, <=, >= is not supported. So we need to use &lt;, &gt;, &lt;= and &gt;=

This will work, try this,

<tree colors="blue:due_date &lt; current_date;" string="Invoice">
    <field name="Due_date" />
    <field name="date_invoice"/>
    <field name="state"/>
</tree>
查看更多
登录 后发表回答