Skip to Content
Menu
This question has been flagged
2 Replies
5283 Views

How to add color in priority fields 

______________________________________________________

Python Code

______________________________________________________

  priority = fields.Selection([

        ('clear','Clear'),

        ('urgent', 'Urgent'),

        ('normal', 'Normal'),

        ('lowand', 'Lowand'),

        ('high','High')],

        copy=False, default='normal', required=True)


  • Red - Urgent

  • Yellow - High

  • Cyan - Normal

  • Gray - Lowand 

  • Clear (if they want to remove priority on the task)


___________________________________

xml code

___________________________________

<field name="priority" widget="priority"/>


Avatar
Discard
Best Answer

Hi,


You can add color to the field through XMLfor eg:-

<field name="priority" widget="priority" decoration-danger="priority == 'urgent'" decoration-muted="priority == 'lowand'"/>



You can try the below-listed decorators.


decoration-success: light green


decoration-primary: light purple


decoration-info: light blue


decoration-muted: light gray


decoration-warning: light brown


decoration-danger: light red


And we can also use some other decorators like bold and italic to enhance the view.


decoration-bf: Bold text


decoration-it: Italic text


You can also refer this blog given below


Link:-

https://www.cybrosys.com/blog/how-to-add-colors-to-tree-view-in-odoo-15


Hope it helps




Avatar
Discard
Best Answer

You can try using badges instead. You can color code the badges easily!

priority==' urgent'" decoration-muted="priority==' lowand'" decoration-warning="priority==' high'"  widget="badge" optional="show"/>

Avatar
Discard