Reputation: 227
I would like give color for particular field value in one2many form view. This is my sample code.
<field name="custom_order_line" mode="tree,kanban" attrs="{'readonly': [('state', '=', 'validate')]}">
<tree colors="red:customs_sale_price < price_unit;green:customs_sale_price > price_unit;" string="Customs Order Lines" editable="bottom">
<field name="customs_sale_price" colors="green:state == 'draft' "/>
<field name="customs_cost_price" colors="red:customs_cost_price < customs_sale_price"/>
</tree>
</field>
Upvotes: 0
Views: 4569
Reputation: 9620
I found a module (web_tree_dynamic_colored_field
) that does what you need. Check the link
Example changing the bg_color
color:
<field name="arch" type="xml">
<tree string="View name">
...
<field name="name" options='{"bg_color": "red: customer == True"}'/>
...
</tree>
</field>
Example changing the fg_color
color:
<field name="arch" type="xml">
<tree string="View name">
...
<field name="name" options='{"fg_color": "white:customer == True"}'/>
...
</tree>
</field>
Note: that you should always use single quotes for fields options
and wrap nested values in double quotes since options
is a JSON object.
If you just want to color rows you can use decorators (only for the 11 version)
decoration-bf - shows the line in BOLD
decoration-it - shows the line in ITALICS
decoration-danger - shows the line in LIGHT RED
decoration-info - shows the line in LIGHT BLUE
decoration-muted - shows the line in LIGHT GRAY
decoration-primary - shows the line in LIGHT PURPLE
decoration-success - shows the line in LIGHT GREEN
decoration-warning - shows the line in LIGHT BROWN
Syntax
<tree decoration-type="field=='value'">
Example
<tree decoration-success="state=='done'">
Upvotes: 1