Hello,
I want to change the tree list item colors with my own field functions.
purchase_view.xml:
<record model="ir.ui.view" id="view_purchase_color_open_orders">
<field name="name">purchase_order_tree_color_open_orders</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_tree"/>
<field name="arch" type="xml">
<xpath expr="//tree[@string='Purchase Order']" position="inside">
<field name="is_green" invisible="1"/>
<field name="is_orange" invisible="1"/>
<field name="is_red" invisible="1"/>
</xpath>
<xpath expr="//tree[@string='Purchase Order']" position="attributes">
<attribute name="colors">
green:is_green=='True';
orange:is_orange=='True';
red:is_red=='True'
</attribute>
</xpath>
</field>
</record>
is_green, is_orange and is_red are my functions and this is the definition:
_columns = {
'is_green': fields.function(_is_green, type = 'boolean'),
'is_orange': fields.function(_is_orange, type = 'boolean'),
'is_red': fields.function(_is_red, type = 'boolean'),
}
The functions works without any problem, but the view color all items green (always the first color).
I also tryed:
<attribute name="colors">
green:('is_green', '=', 'True');
orange:('is_orange', '=', 'True');
red:('is_red', '=', 'True')
</attribute>
with the same result.
Is this the right way, or is there another opportunity to solve the problem?
Regards,
Sebastian