Help

4

How to change color of line in tree view

Avatar
John Pia Jr

Hello,

I need to know hwot ochange the color of a line (record) in a tree view based on if there is any content within the notes field of the form.. 

 

Example

I want the line text to change to red inf there are any notes in the notes field on a specific delivery order. How can I do this? something like 

if notes != '' then ...

Avatar
Discard
9Answers
11
3Comments
Avatar
Discard
Avatar
Nebil Aydi
-

Nice thnx :)

Avatar
vineeth george
-

Good one :)

Avatar
Ignacio Segura
-

thnx!!

8
Avatar
Ray Carnes
Best Answer

<tree colors="red:notes!=False'">

Take a look at an existing XML definition of a treeview that uses colors for more help.


 

1Comment
Avatar
Discard
Avatar
Chandni Gandhi
-

I want to change the color of Particular column in tree view. Please help me.

for eg. Change the background color of amount in sale order tree view.

7
Avatar
Dhinesh
Best Answer

Hi, try this example...

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>

1Comment
Avatar
Discard
Avatar
Chandni Gandhi
-

What is Shop ? Is it field?

2
Best Answer

For Odoo 11 in original view:

<tree decoration-success="state=='done'" decoration-success="state=='undone'">

...

</tree>

on inherited view:

<xpath expr="//tree" position="attributes">

    <attribute name="decoration-danger">approved == False</attribute>

    <attribute name="decoration-bf">approved == True</attribute>

   <attribute name="decoration-success">approved == True</attribute>

</xpath>

Avatar
Discard
1

If you want to compare several values or make operations you can also do something like:

<tree colors="blue:state == 'draft';black:state in ('proforma','proforma2','open');gray:state == 'cancel';orange:date_due &lt; current_date;" string="Invoice" default_order="date_invoice">


take note that in xml you can not use <, >, >=,<= because that simbols are part of the structure, so instead use &lt;, &gt;, &lt;= and &gt;=

Avatar
Discard
0
Avatar
Jeswin Joseph
Best Answer

Using a decoration tag is a better idea!
There are many defined colors for decoration and we can apply them based on conditions in  tree as well as in fields

 



Avatar
Discard
0
Best Answer

If you wanna combine two decorators, can use "or" and "and" operators in the decorator, for example:


decoration-success="state=='offer_received' or state=='offer_accepted'"


Avatar
Discard
0
Avatar
Andreas Tolstov
Best Answer

I would make it with custom web module.

JS: RPC call with list of ID's from each row from listview

Python controller: response with list of ID's what have note field not empty.

JS: change color for this ID's

Avatar
Discard
0
Avatar
School of Thought
Best Answer

For Odoo13, Odoo14, Odoo15 

decoration-danger="color_definer=='0'"


Avatar
Discard