xml - How to display an icon in Odoo ListView? -
i want show warning icon in odoo tree view if score <= avg
<field name="score"/> <field name="avg"/>
your python code (add field score_lt_avg
model has score
, avg
fields):
@api.multi @api.depends('score', 'avg') def _compute_score_lt_avg(self): record in self: record.score_lt_avg = (record.score <= record.avg) score_lt_avg = fields.boolean( compute='_compute_acore_lt_avg', string='score equal to/lower average', )
your xml code (you must add score
, avg
, score_lt_avg
form view, not tree view, otherwise computed field not work):
<field name="score"/> <field name="avg"/> <field name="score_lt_avg" invisible="1"/> <span class="fa fa-exclamation-triangle" attrs="{'invisible': [('score_lt_avg', '=', false)]}"/>
Comments
Post a Comment