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_sublocation_count

View 17.0 View 19.0
Inputs Method Outputs
  • parent_path
+ if not self.ids:  # pragma: no cover
+             self.sublocation_count = 0
+             return
+ count_by_location = dict[Self, int](
+             self.env["fsm.location"]._read_group(
+                 domain=Domain.AND(
+                     [
+                         Domain("parent_id", "child_of", self.ids),
+                         Domain("parent_id", "!=", False),
+                     ]
+                 ),
+                 groupby=["parent_id"],
+                 aggregates=["__count"],
+             )
+         )
for loc in self:
-             loc.sublocation_count = self.comp_count(0, 0, loc)
+             loc.sublocation_count = sum(
+                 child_count
+                 for location, child_count in count_by_location.items()
+                 if location.parent_path.startswith(loc.parent_path)
+             )
  • sublocation_count

Back to entity