跳至内容
菜单
此问题已终结
2 回复
7787 查看

Hi, I want to change the color of the kanban view based on the expiration date  

形象
丢弃

a nice idea, did you find a solution?

最佳答案

Hi

You can use the below XML code to set the color of a kanban view.

<kanban>
<!-- Other fileds-->
<field name="color"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="{{'oe_kanban_color_' + kanban_getcolor(record.color.raw_value) }} oe_kanban_card oe_kanban_global_click oe_semantic_html_override">
<!-- Define view-->
</div>
</t>
</templates>
</kanban>

And inside your model define a color field and compute its value according to the expiration date.

color = fields.Integer('Color', compute='_get_color')

def _get_color(self):
"""Compute Color value according to the conditions"""
for rec in self:
if rec.expiry_date:
rec.color = 1
else:
rec.color = 2

Hope it helps

形象
丢弃
最佳答案

try this

decoration-danger="condition"

形象
丢弃
相关帖文 回复 查看 活动
1
3月 15
4833
2
5月 25
1089
1
8月 21
3382
1
3月 19
13226
2
10月 16
5046