Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Fleet History

Entity: hr.employee

Compute Method: _compute_employee_cars_count

Inputs Method Outputs
  • work_contact_id
  • work_contact_id.ids
  • id
rg = self.env['fleet.vehicle.assignation.log']._read_group([
            ('driver_employee_id', 'in', self.ids), ('driver_id', 'in', self.work_contact_id.ids),
        ], ['driver_employee_id'], ['__count'])
cars_count = {driver_employee.id: count for driver_employee, count in rg}
for employee in self:
            employee.employee_cars_count = cars_count.get(employee.id, 0)

Back to entity