Hello Odooers, Odoogig and Odoo Lovers,
In this Odoo Technical Tutorial, I would like to explain how to add colors in tree view odoo.
Sometime, it’s required to show the odoo tree view lines record in different colours to easy identification.like green colour for indicate approved record, red colour for expectation record. We will show how can we change list view lines colours based on condition.
- Below screen show how normal tree view looks in odoo
- You can change colors of each record based on the condition in tree view
- For eg., a record has 4 states so you can set different colors for each state, so when you see records in tree view then you can easily identify the record
- Below example shows how to add colors in tree view of odoo
Example to change colors in odoo
<tree decoration-success="state == 'done'" decoration-danger="state == 'cancel'">
- As shown decoration is used to set different colors based on condition
- In above eg., if state is done then color of record will be green in tree view, if state in cancel then color of record will be red in tree view
- It means using decoration with success will return green color and decoration with danger will return red color.
- For more colors you can refer below odoo color chart
|decoration-bf||Record will be bold|
|decoration-it||Record will be italic|
|decoration-danger||Record will be light red|
|decoration-info||Record will be light blue|
|decoration-muted||Record will be light grey|
|decoration-primary||Record will be light purple|
|decoration-success||Record will be light green|
|decoration-warning||Record will be light brown|
- Below screen shows that how tree view in odoo will look with colors