Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
6424 Weergaven

If my field value is < 10, then it should have red color,

If my field value is between 10< my field value < 15, then it should have yellow color,

If my field value is > 15, then it should have green color.

Avatar
Annuleer

This Odoo app allows users to dynamically change the background and text color of any integer field based on a threshold value. The app introduces a customizable widget that automatically adjusts the visual representation of integer fields, allowing users to define their own colors for values below and above the threshold. Whether for financial figures, performance metrics, or other numeric values, users can easily tailor the display according to their preferences.
https://apps.odoo.com/apps/modules/17.0/mh_integer_field_color_widget

Beste antwoord

You can try with bellow code when you don't get any default Odoo classes for this.

In Python file : 

        number = fields.Char('Number')
    field_01 = fields.Char('Field 01', default=False)
    field_02 = fields.Char('Field 02', default=False)
    field_03 = fields.Char('Field 03', default=False)
        @api.onchange('number')
    def get_field_color(self):
            if self.number:
                if int(self.number) <= 10:
                    self.field_01 = self.number
                    self.field_02 = False
                    self.field_03 = False
                if 10 < int(self.number) <= 15:
    self.field_01 = False
    self.field_02 = self.number
    self.field_03 = False

    if int(self.number) > 15:
   self.field_01 = False
   self.field_02 = False
   self.field_03 = self.number 
Xml File :


Avatar
Annuleer

this will work in odoo 15 ?

Auteur

I can't see your xml file. will you please update that.

@Manoj use can use following xml code:
<label for="number" string="Number"/>
<div>
<field name="number" class="oe_edit_only" nolabel="1"/>
<field name="field_01" class="oe_read_only" attrs="{'invisible':[('field_01','=', False)]}" style="color:Red" nolabel="1"/>
<field name="field_02" class="oe_read_only" attrs="{'invisible':[('field_02','=', False)]}" style="color:Yellow" nolabel="1"/>
<field name="field_03" class="oe_read_only" attrs="{'invisible':[('field_03','=', False)]}" style="color:Green" nolabel="1"/>
</div>

Beste antwoord

Hello

Following module will fullfill your needs

https://apps.odoo.com/apps/modules/15.0/integer_widget_cr/

Avatar
Annuleer