Odoo Help


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.


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

Anabela Damas
on 2/9/16, 6:38 AM 517 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

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)


Asked: 2/9/16, 6:38 AM
Seen: 517 times
Last updated: 2/9/16, 11:00 AM