自定义字体颜色 Field Odoo

Custom font-color Field Odoo

模型有属性状态

status = fields.Selection([
    ('Progreso', 'En progreso'),
    ('Completa', 'Completa'),
    ('Anulada', 'Anulada'),
    ('En espera', 'En espera')
], 'Estado')

景色

<div class="card-text">
     <field name="status" />
 </div>

我希望每个状态都有特定的字体颜色:

Progreso:蓝色

完成:绿色

谢谢

您可以试试这个,但仅限于颜色列表。

<field name = 'status' widget="selection" decoration-danger="status=='Progreso'" decoration-info="status=='Completa'" decoration-muted="status=='Anulada'" decoration-success="status=='En espera'"/>

decoration-bf - BOLD

decoration-it - ITALICS

decoration-danger - LIGHT RED

decoration-info - LIGHT BLUE

decoration-muted - LIGHT GRAY

decoration-primary - LIGHT PURPLE

decoration-success - LIGHT GREEN

decoration-warning - LIGHT BROWN

你也可以试试这个...

<field name = 'status' widget="selection" t-att-style="'color: #f00;' if status == 'Progreso' else ('color: #00f;' if status == 
     'Completa' else 'color: #696969;')" />