Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Fleet
Entity: fleet.vehicle.log.contract
Compute Method: _compute_days_left
| Inputs | Method | Outputs |
|---|---|---|
|
"""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())
+ today = fields.Date.context_today(self)
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
|
|
