Odoo Help

Welcome!

This community 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.

0

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

By
ASP
on 4/29/14, 8:45 AM 1,955 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 :)

Cheers

ASP:)

*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
3

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
3577
| 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>
</tree>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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