Reputation: 43
I need change to color background red if expired/date deadline in less than date now, and change to color background green if expired/date deadline more than date now, and change to color background orange if expired/date deadline in less than 1 days and 3 days
<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>
I have not found a way to change color background orange if expired in less than 1 days until 3 days.
Upvotes: 1
Views: 3280
Reputation: 1108
You have a condition problem for orange test:
( ( record.eth_current_stage_deadline.raw_value gt new Date() ) and (record.eth_current_stage_deadline.raw_value - new Date() lt 3*86400000) )
Note that there are two comparisons like this:
(date_val > today) and (date_val - today < 3 days)
The value 86400000 = 24 * 60 * 60 * 1000 corresponding to one day in milliseconds.
Upvotes: 0