Skip to content

Commit 1e92359

Browse files
committed
fix(spp_demo): use area_level filter instead of non-stored child_ids
child_ids on spp.area is a computed non-stored One2many that cannot be used in search domains. Use area_level (stored) to find leaf areas.
1 parent eca97d2 commit 1e92359

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

spp_demo/models/demo_data_generator.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,11 @@ def _get_leaf_areas(self):
371371
recordset: spp.area records at the deepest available level
372372
"""
373373
Area = self.env["spp.area"]
374-
375-
# Query only leaf areas directly: areas that have no children.
376-
# This is a single SQL query rather than loading all areas into memory.
377-
leaf_areas = Area.search([("child_ids", "=", False)])
378-
379-
# Fallback: if no leaf areas found, return all areas
380-
return leaf_areas if leaf_areas else Area.search([])
374+
all_areas = Area.search([])
375+
if not all_areas:
376+
return all_areas
377+
max_level = max(all_areas.mapped("area_level"))
378+
return all_areas.filtered(lambda a: a.area_level == max_level)
381379

382380
def get_group_vals(self, fake):
383381
registration_date = self.get_random_date(

0 commit comments

Comments
 (0)