List view decorations in Odoo provide a way to visually highlight records or fields in the list/tree view based on specific conditions. These decorations can improve the user experience by making it easier to identify important records. In Odoo 18, several attributes can be used for list view decorations, offering flexibility in managing your data. Here’s an overview of the key decoration attributes and their usage.
In Odoo, the <list> element utilizes the decoration-type attribute to apply visual indicators to a list view based on the value of a particular field. The decoration-type attribute enables you to define a condition under which the decoration will be applied.
The syntax for using decoration attributes in a list view definition is as follows:
<list decoration-type="field=='value'">
For Example :
<list string="Next Activities"
decoration-danger="date_deadline < current_date and active == True"
decoration-warning="date_deadline == current_date and active == True"
decoration-success="date_deadline > current_date and active == True"
default_order="date_deadline" create="false">
1. decoration-info
The decoration-info attribute is used to highlight records in blue, typically indicating information that needs attention but isn’t critical. You can apply this decoration based on a condition.
2. decoration-danger
The decoration-danger attribute highlights records in red, typically used to indicate a critical issue or error that requires immediate attention.
3. decoration-success
The decoration-success attribute is used to indicate successful or positive conditions, highlighted in green. It’s commonly used for completed tasks, paid invoices, or stock levels above a threshold.
4. decoration-muted
The decoration-muted attribute allows you to gray out certain records. It’s often used to indicate inactive or archived records.
5. decoration-warning
This attribute highlights records in yellow, indicating a warning or something that needs caution.
7. decoration-it (Italic)
This attribute renders the field in italic text. It’s a subtler way of decorating the view, often used for less critical visual distinctions.
8. decoration-bf (Bold)
The decoration-bf attribute applies bold formatting to fields.
9. decoration-primary
The decoration-primary attribute is used to highlight records in light purple, typically indicating information that needs attention but isn’t critical. You can apply this decoration based on a condition.
List view decorations in Odoo 18 provide a useful tool for enhancing the visibility and management of records. By using the various decoration attributes, you can create more intuitive and informative views for your users.
To read more about Tree View Decoration Attributes in Odoo 17, refer to our blog Tree View Decoration Attributes in Odoo 17.