|
|
"""return a dict with as value for each contract an integer
if contract is in an open state and is overdue, return 0
if contract is in a closed state, return -1
otherwise return the number of days before the contract expires
"""
today = fields.Date.from_string(fields.Date.today())
for record in self:
if record.expiration_date and record.state in ['open', 'expired']:
renew_date = fields.Date.from_string(record.expiration_date)
diff_time = (renew_date - today).days
record.days_left = diff_time if diff_time > 0 else 0
record.expires_today = diff_time == 0
else:
record.days_left = -1
record.expires_today = False
|
|