'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'

@api.depends('expiration_date', 'state')
def _compute_days_left(self):

    for record in self:
        if (record.expiration_date and ((record.state == 'open') or (record.state == 'toclose'))):
            today = fields.Date.from_string(fields.Date.today())
            renew_date = fields.Date.from_string(record.expiration_date)
            diff_time = (renew_date - today).days
            record.days_left = (((diff_time > 0) and diff_time) or 0)
        else:
            record.days_left = (-1)
