在odoo中更改颜色背景看板

change color background kanban in odoo

如果 expired/date 截止日期早于现在,我需要将背景色更改为红色,如果 expired/date 截止日期早于现在,我需要将背景色更改为绿色,如果 expired/date 截止日期早于现在,我需要将背景色更改为橙​​色expired/date 截止日期不到 1 天和 3 天

<div t-if="record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value gt (new Date())" style="margin: 0px; background-color: #00FF00;">                                                                                                               
    <b>Stage Deadline:</b> <t t-if="record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value lt (new Date())" t-set="redo">oe_kanban_text_red</t>
            <span t-attf-class="#{redo || ''}"><i><field name="eth_current_stage_deadline"/></i></span>    
</div>

<div t-if="record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value lt (new Date())" style="margin: 0px; background-color: #FF0000;">                                                                                                               
    <b>Stage Deadline:</b> <t t-if="record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value lt (new Date())" t-set="redo">oe_kanban_text_red</t>
            <span t-attf-class="#{redo || ''}"><i><field name="eth_current_stage_deadline"/></i></span>    
</div>

<div t-if="(record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value - new Date()) == 3" style="margin: 0px; background-color: #FF8C00;">                                                                                                               
    <b>Stage Deadline:</b> <t t-if="record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value lt (new Date())" t-set="redo">oe_kanban_text_red</t>
            <span t-attf-class="#{redo || ''}"><i><field name="eth_current_stage_deadline"/></i></span>    
</div>

如果在不到 1 天到 3 天内过期,我还没有找到更改颜色背景橙色的方法。

您的橙色测试条件有问题:

( ( record.eth_current_stage_deadline.raw_value gt new Date() ) and (record.eth_current_stage_deadline.raw_value - new Date() lt 3*86400000) )

注意有两个这样的比较:

(date_val > today) and (date_val - today < 3 days)

值86400000 = 24 * 60 * 60 * 1000对应1天毫秒数