Enable Dark Mode!
By: Aiswarya JP

Tree View Decoration Attributes in Odoo 15

Technical Odoo 15

In Odoo, we can add colors and styles to each record in a tree view using the decoration attributes. This feature will help us to identify and differentiate records in tree view based on some factors.

The syntax for adding decoration attributes in the tree view definition is as follows;

	<tree decoration-type=”field==’value'”>

The image below depicts the tree view of the inventory module.


From the above image, we can see that records in the tree view are highlighted with different colors like green, blue, and grey based on the value in the status field of the corresponding record. The decoration attributes given in the tree view definition help to show these records in a different color.

For example, the decoration-success attribute indicates green color. Likewise, there are more decoration attributes that can be used in the Odoo tree view.

Let’s check how to provide different colors to tree view lines using decoration attributes.

The below image shows a tree view of the custom module.


Each record in the above tree view will be highlighted based on the value of the Status field in corresponding records.

Student records with the status Excellent will be in green, Good will be blue, Average will be yellow, and Insufficient will be Red.

Below shown is the tree view definition of this custom module,

<record id="student_mark_tree_view" model="ir.ui.view">
   <field name="name">student.mark.tree</field>
   <field name="model">student.mark</field>
   <field name="arch" type="xml">
       <tree string="Marks" decoration-success="grade_status == 'excellent'"
             decoration-info="grade_status == 'good'" decoration-danger="garde_status == 'insufficient'"
             decoration-warning="grade_status == 'average'">
           <field name="name" decoration-bf="1"/>
           <field name="age"/>
           <field name="grade_point"/>
           <field name="grade_status"/>

After adding decoration attributes, the records in the tree view will be displayed as shown below,


This is how we can differentiate our records in a tree view using decoration attributes.

Below listed are the allowed decoration attributes and their property that can be used in the tree view;

1. decoration-bf: shows the record in Bold

2. decoration-it: shows the record in Italics

3. decoration-danger: shows the record in Light Red

4. decoration-info: shows the record in Light Blue

5. decoration-muted: shows the record in Light Gray

6. decoration-primary: shows the record in Light Purple

7. decoration-success: shows the record in Light Green

8. decoration-warning: shows the record in Light Brown

This is how we can add decoration attributes in the odoo tree view.

If you need any assistance in odoo, we are online, please chat with us.


Leave a comment




Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message