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

Module: Field Service

Entity: fsm.location

Compute Method: _compute_contact_count

Inputs Method Outputs
if not self.ids:  # pragma: no cover
            self.contact_count = 0
            return
count_by_location = dict[Self, int](
            self.env["res.partner"]._read_group(
                domain=Domain("service_location_id", "child_of", self.ids),
                groupby=["service_location_id"],
                aggregates=["__count"],
            )
        )
for loc in self:
            loc.contact_count = sum(
                contact_count
                for location, contact_count in count_by_location.items()
                if location.parent_path.startswith(loc.parent_path)
            )

Back to entity