Odoo Help


How to change the color of a field inside a form depending on a value?

Anabela Damas
on 2/9/16, 6:38 AM 2,331 views


I want to in a form view have a field that depending on his value changes the color. 

If is diferent than zero I want this number to show in red color , if it is zero I want the field to be green. 

I've tried this way , but nothing happens.


<form string="Sales Order"> 
<page name="SO_payment">
    <group class="oe_subtotal_footer oe_right" colspan="2" name="payment_total">                           <div class="oe_subtotal_footer_separator oe_inline o_td_label">
          <label for="to_pay" />                   
         <field name="to_pay" nolabel="1" class="oe_subtotal_footer_separator" widget='monetary' options="{'currency_field': 'currency_id'}" colors="{'red':to_pay&gt;0}"/> 


I just want the number to have the color. 


you want only field name="to_pay" color or all fields color.

Vishal Gediya
on 2/9/16, 7:36 AM

I've updated the question.

Versão Integral, Anabela Damas
on 2/9/16, 11:01 AM
Vishal Gediya
On 2/9/16, 7:45 AM

If you want all fields color then give colors attribute in <tree>

<tree string="Configuration" colors="green:no == 0;red:no > 0">
    <field name="no" />

For tree the answer is rigth. But I need in a form just the field.

Versão Integral, Anabela Damas
on 2/9/16, 11:02 AM

you need only for to_pay filed.

Vishal Gediya
on 2/10/16, 12:57 AM

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: 2/9/16, 6:38 AM
Seen: 2331 times
Last updated: 10/2/17, 7:06 AM