In odoo treeview we can colorize record lines depend on specific field. In this example i make each line green and red color based on field 'state' which is selection field ('confirm','reject'). this is also work in treeview of One2many.
Simple isn't ? Questions comment down below.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<tree decoration-success="state=='confirm'" decoration-danger="state=='reject'"> | |
<field name="product_id"/> | |
<field name="state" invisible="1"/> | |
</tree> | |
<!-- Here is the detail for available color --> | |
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 |
The next question is: how to change color of for example decoration-danger to BLACK? for example in specific field only.
ReplyDeleteand how to add new decoration attribute?