@@ -29,9 +29,17 @@ class RepairOrder(models.Model):
2929 "stock.picking" , compute = "_compute_preparation_picking_ids"
3030 )
3131 repair_preparation_enabled = fields .Boolean (
32- related = "warehouse_id.repair_preparation_enabled "
32+ compute = "_compute_repair_preparation_enabled "
3333 )
3434
35+ @api .depends ("warehouse_id.repair_preparation_enabled" , "location_id.usage" )
36+ def _compute_repair_preparation_enabled (self ):
37+ for rec in self :
38+ rec .repair_preparation_enabled = bool (
39+ rec .warehouse_id .repair_preparation_enabled
40+ and rec .location_id .usage != "customer"
41+ )
42+
3543 @api .depends ("warehouse_id" , "repair_preparation_enabled" )
3644 def _compute_preparation_picking_type_id (self ):
3745 for rec in self :
@@ -106,11 +114,23 @@ def _run_preparation_procurements(self, operations):
106114 )
107115
108116 def action_validate (self ):
109- res = super ().action_validate ()
110- for rec in self :
111- if not rec .repair_preparation_enabled :
117+ """repairs performed at a customer location don't require a preparation flow
118+ and do not need to check available quantities (handled in super)"""
119+ customer_repairs = self .filtered (
120+ lambda repair : repair .location_id .usage == "customer"
121+ )
122+ non_customer_repairs = self .filtered (
123+ lambda repair : repair .location_id .usage != "customer"
124+ )
125+ res = customer_repairs .action_repair_confirm ()
126+ if not non_customer_repairs :
127+ return res
128+ res = super (RepairOrder , non_customer_repairs ).action_validate ()
129+ for repair in non_customer_repairs :
130+ if not repair .repair_preparation_enabled :
112131 continue
113- rec ._run_preparation_procurements (rec .operations )
132+ repair ._run_preparation_procurements (repair .operations )
133+
114134 return res
115135
116136 def action_repair_end (self ):
0 commit comments