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.model

Compute Method: _compute_vehicle_count

Inputs Method Outputs
  • id
group = self.env['fleet.vehicle']._read_group(
            [('model_id', 'in', self.ids)], ['model_id'], aggregates=['__count'],
        )
count_by_model = {model.id: count for model, count in group}
for model in self:
            model.vehicle_count = count_by_model.get(model.id, 0)

Back to entity