콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
8284 화면

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
5168
2
5월 25
1635
1
8월 21
3657
1
3월 19
13571
2
10월 16
5303