Hey, so we are trying to implement a andon system in our kanban view depending on a date field.
If the date is within 90 days we need it to be one color,
If the date is within 60 days we need it to be a different color,
if the date is within 30 days we need it to be a different color.
Ive created a cron in the model that runs with no errors however it isnt actually updating any values.
Is there somthing im missing here, thanks!
@api.model
def cron_andon_color_set(self):
today = fields.Date.today()
contracts = self.env['account.analytic.account'].search([('x_contact', '!=', False),('date_end','!=',False)])
for record in contracts:
if record['date_end'] != False:
end_date = fields.Date.from_string(str(record['date_end']))
if today-timedelta(days=90) <= end_date <= today:
record['x_color'] = 1
elif today-timedelta(days=60) <= end_date <= today:
record['x_color'] = 2
elif today-timedelta(days=30) <= end_date <= today:
record['x_color'] = 3
else:
#Kinda broke if we get to here
record['x_color'] = False