Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
8115 Lượt xem

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

Ảnh đại diện
Huỷ bỏ

a nice idea, did you find a solution?

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

try this

decoration-danger="condition"

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 15
5044
2
thg 5 25
1418
1
thg 8 21
3545
1
thg 3 19
13438
2
thg 10 16
5216