In this article, you will learn how to bold font, italic a text, and give colors to an Odoo field based on conditions in Tree View Column. To decorate a field in Odoo15 is now not a big deal.
How to Bold Text in Odoo Tree View Column
To bold text in the tree view in Odoo, we are going to use decoration-bf="1". We will use this decorator in tree view fields like below.
Read More: How to Align Left [float, integer] Fields in Tree View in Odoo
<field name="email" decoration-bf="1"/>
How to Italic a Text Odoo Tree View Column
Odoo provides a beautiful decorator to make the text italic, we just need to put this decorator decoration-it="1" in tree view fields.
Read More: Color Field and Color Picker (color_picker) Widgets in Odoo
<field name="email" decoration-it="1"/>
How to Color Fields or Specific Column of a Tree View in Odoo
You can use the below decorators to give color to a column or specific value of Odoo fields.
Read More: How to Use ProgressBar, Gauge and Percentpie Widgets In Odoo
- decoration-success
- decoration-primary
- decoration-danger
- decoration-warning
- decoration-info
- decoration-muted
Decoration | Description |
---|---|
decoration-bf | Shows the line or specific field in BOLD |
decoration-it | Shows the line or specific field in ITALICS |
decoration-danger | Shows the line in LIGHT RED |
decoration-info | Shows the line in LIGHT BLUE |
decoration-muted | Shows the line in LIGHT GRAY |
decoration-primary | Shows the line in LIGHT PURPLE |
decoration-success | Shows the line in LIGHT GREEN |
decoration-warning | Shows the line in LIGHT BROWN |
Below is the example of decorators in Odoo, you can use operators like (==, !=, in, not in, and, or, <, >) in decorators to make it conditional.
Read More: Use Handle Widget in Odoo to Reorder Records in Tree View
<field name="state"
decoration-warning="state == 'progress'"
decoration-success="state == 'done'"
decoration-info="state not in ('progress', 'done', 'cancel')"/>
Similarly, you can use "decoration-danger" and "decoration-muted" decorators to give colors to a specific field in Odoo Tree View Column. You can also use "or" and "and" operators in decorators.
<field name="state" decoration-warning="state == 'cancel' or state == 'terminate'"/>
You can also use less than operator to show colors in the tree view column conditionally.
<tree string="Events" decoration-danger="(seats_max and seats_max<seats_reserved)">
0 Comments