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

Module: Maintenance Location

Entity: maintenance.location

Compute Method: _compute_child_equipment_ids

Inputs Method Outputs
all_locations = self.env["maintenance.location"].search(
            [("id", "child_of", self.ids)]
        )
all_equipments = self.env["maintenance.equipment"].search(
            [("location_id", "in", all_locations.ids)]
        )
for location in self:
            descendant_locs = all_locations.filtered(
                lambda sub_loc, loc=location: sub_loc.parent_path
                and sub_loc.parent_path.startswith(loc.parent_path)
                and sub_loc.id != loc.id
            )
            location.child_equipment_ids = all_equipments.filtered(
                lambda eq, d_locs=descendant_locs: eq.location_id in d_locs
            )

Back to entity