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

Compute Method: _compute_equipment_ids

View 17.0 View 19.0
Inputs Method Outputs
  • equipment_ids
  • company_id
  • company_id.auto_populate_equipments_on_order
  • location_id
  • location_id.id
  • company_id.id
+ for rec in self:
+             # Clear equipments that no longer match the order company
+             to_remove = rec.equipment_ids.filtered(
+                 lambda equipment, rec=rec: equipment.company_id != rec.company_id
+             )
+             if to_remove:
+                 rec.equipment_ids = [
+                     Command.unlink(equipment.id) for equipment in to_remove
+                 ]
+             # If we have no equipments, auto populate if needed
+             if (
+                 rec.company_id.auto_populate_equipments_on_order
+                 and not rec.equipment_ids
+             ):
+                 rec.equipment_ids = self.env["fsm.equipment"].search(
+                     domain=Domain.AND(
+                         [
+                             Domain("current_location_id", "=", rec.location_id.id),
+                             Domain("company_id", "=", rec.company_id.id),
+                         ]
+                     )
+                 )
  • equipment_ids

Back to entity