December 2018
Beginner to intermediate
404 pages
10h 14m
English
For more complex logic, we can store the result of an expression into a variable to use it later in the template. This is to be done using the t-set directive, naming the variable to set followed by the t-value directive, with the expression calculating the value to assign.
As an example, the following code renders missed deadlines in red, just as in the previous section, but uses a red_or_black variable for the CSS class to use, as shown in the following:
<t t-set="red_or_black" t-value=" record.priority.raw_value gte '2'
? 'oe_kanban_text_red' : ''" />
<li t-att-class="red_or_black">
<field name="user_id" />
</li>
Variables can also be assigned HTML content, as in the following example:
<t t-set="calendar_sign"> ...
Read now
Unlock full access