콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
6420 화면

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.

아바타
취소

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

베스트 답변

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 :


아바타
취소

this will work in odoo 15 ?

작성자

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>

베스트 답변

Hello

Following module will fullfill your needs

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

아바타
취소