Odoo Help


How to add css to any row in a tree view based on a condition

on 4/29/14, 8:45 AM 2,774 views

Hi Guys,

I'm using OpenERP 7 & want to add background color to specific rows in a tree view, based on certain value of a field.

Ex: Suppose say I have name, phone, status fields in my model. Then I want to color code my rows in a tree view, based on the value of status field. If status is Single, the row will be RED, If status is Married, the row will be Green etc..

Please help me on this. Any help would be appreciated :)



*Hi, add this in your xml file...* <tree string="Sample" colors="red:state=='single';green:state=='married' "> <field name="title" string="Name"/> </tree>

Dhinesh - Technical Consultant, Sodexis Inc
on 5/26/14, 8:32 AM

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 4/29/14, 12:09 PM

Hi, use the below code...

In py file

'status' : fields.selection([('single','Single'),('married','Married')],'Status?'),

In xml file

<tree string="Status" colors="red:shop=='single';green:shop=='married' ">
    <field name="name"></field>
    <field name="status"></field>

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/29/14, 8:45 AM
Seen: 2774 times
Last updated: 3/16/15, 8:10 AM