The most effective method to Add Colors to Tree View in Odoo 13!

How to Add Colors in Tree View of Odoo 13 Version

In Odoo, we may need to separate records dependent on certain components. We have seen them in certain modules, for example, in the list, the records are isolated with various colors. it’s very easy to add colors in the tree view of odoo 13 version. In view of the conditions, the records are shown in various colors. For this situation, it turns out to be profoundly useful to discover and recognize the records from the list dependent on the shading. In Odoo it has been utilized in the greater part of the modules. Here we can see the list_view perspective on an activity in the Inventory.

how to manage tree view in odoo 13
Here we can see a portion of the records in red shading. Here they have separated the records dependent on their status. We can see beautification danger(red shading) for the records which are not in the state – done or dropped.

In this blog, I will tell you the best way to add colors to the records in the tree view in a custom module. In light of the information in the record, one can give shading to the fields in the tree view. As we probably are aware on the off chance that we are giving various colors to the record in the tree view and it will be simpler to distinguish the records. So how about we perceive how we can change tree view lines hues dependent on condition.

This is the ordinary tree perspective on my custom module School:

So as to give shading for the records in odoo, we need to include embellishments around the tree view. Here I am going to isolate the records dependent on age. I am attempting to isolate the records of the understudy whose age is 20 or under 20 and whose age is over 20. As should be obvious the code underneath I have given design threat for the records with age not exactly or equivalent to 20 which will enhance the record with red shading. The adornment accomplishment for the records with age more prominent than 20 will restore the records with green shading. Additionally, we have more alternatives for enriching records in various hues.

Each choice is portrayed beneath.

Here is the tree perspective on the model understudy. understudy

<record id=”view_student_record_tree” model=”ir.ui.view”>

<field name=”name”>Student</field>

<field name=”model”>student.student</field>

<field name=”priority”>2</field>

<field name=”arch” type=”xml”>

<tree design danger=”age &lt;= 20″ adornment success=”age &gt; 20″ default_order=”nationality desc”>

<field name=”name”/>

<field name=”middle_name”/>

<field name=”dob”/>

<field name=”age”/>

<field name=”nationality”/>

</tree>

</field>

</record>

The records subsequent to giving the shading will be as per the following. Here we can see the records for which the age is more prominent than 20 is shown in green shading and records for which the age is equivalent to or under 20 showed in red shading.

(image…………………………………………………………………………………..)

So, this is the manner in which it works.

Also, we can give various hues for the improvement by utilizing the accompanying codes:

decoration-muted: records will be light grey

decoration-danger: records will be light red

decoration-success: records will be light green

decoration-primary: records will be light purple  

decoration-info: records will be light blue 

decoration-warning: records will be light brown

decoration-bf: records will be bold

decoration-it: records will be italic

Along these lines, we can add shading to the tree perspective on any Custom module.  For more Odoo 13 Blogs Visit “ODOO ERP BLOGS

2020-03-02T10:01:09+00:00 March 2nd, 2020|Features in Odoo 13|0 Comments

About the Author: