diff --git a/repair_order_type/models/repair_line.py b/repair_order_type/models/repair_line.py index 5f11ea4..dc0a4df 100644 --- a/repair_order_type/models/repair_line.py +++ b/repair_order_type/models/repair_line.py @@ -6,7 +6,7 @@ class RepairLine(models.Model): _inherit = "repair.line" - @api.onchange("type", "repair_id", "repair_id.type_id") + @api.onchange("type", "repair_id") def onchange_operation_type(self): res = super().onchange_operation_type() if self.type == "add": @@ -16,3 +16,14 @@ def onchange_operation_type(self): self.location_id = self.repair_id.type_id.location_dest_id.id self.location_dest_id = self.repair_id.type_id.location_id.id return res + + @api.depends("repair_id.type_id") + def _compute_location_id(self): + res = super()._compute_location_id() + if self.type == "add": + self.location_id = self.repair_id.type_id.location_id.id + self.location_dest_id = self.repair_id.type_id.location_dest_id.id + else: + self.location_id = self.repair_id.type_id.location_dest_id.id + self.location_dest_id = self.repair_id.type_id.location_id.id + return res