如果得分< = avg
,我想在Odoo树视图中显示警告图标 <field name="score"/>
<field name="avg"/>
答案 0 :(得分:1)
您的Python代码(将字段score_lt_avg
添加到包含score
和avg
字段的模型中:
@api.multi
@api.depends('score', 'avg')
def _compute_score_lt_avg(self):
for 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 than average',
)
您的XML代码(您必须将score
,avg
和score_lt_avg
添加到表单视图中,而不仅仅是树视图,否则计算字段将不起作用):
<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)]}"/>
答案 1 :(得分:1)
并且不知道它是否是最佳方式,但我使用button
标签在TreeView中显示图标
<button readonly="True" class="oe_inline oe_stat_button" icon="STOCK_DIALOG_WARNING" attrs="{'invisible': [('score_lt_avg', '=', False)]}"/>