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_has_open_contract

Inputs Method Outputs
open_contracts = self.env['fleet.vehicle.log.contract'].search([
            ('vehicle_id', 'in', self.vehicle_id.ids),
            ('state', '=', 'open'),
            ('expiration_date', '>=', 'today')
        ])
open_contract_keys = {(c.vehicle_id.id, c.cost_subtype_id.id) for c in open_contracts}
for log_contract in self:
            log_contract.has_open_contract = (log_contract.vehicle_id.id, log_contract.cost_subtype_id.id) in open_contract_keys

Back to entity