From a2574b45aef1ff6ff3a221b996d0bb0dda2a8c74 Mon Sep 17 00:00:00 2001
From: yhu-odoo <yhu@odoo.com>
Date: Mon, 4 Sep 2023 14:44:34 +0200
Subject: [PATCH] [FIX] mrp: wrong workorder state in tests

As a good pratice, in compute method, we assign a default value before
we do the actual calculation to avoid issues like no value is assigned
for fields with required=True. For example `reservation_state`:
https://github.com/odoo/odoo/blob/7ebc8cc5771d069b32722d493dd0ae5341e54c96/addons/mrp/models/mrp_production.py#L572
However, since workorder state is depends on this field:
https://github.com/odoo/odoo/blob/7ebc8cc5771d069b32722d493dd0ae5341e54c96/addons/mrp/models/mrp_workorder.py#L158-L159
For some reason, this unexpected false value can lead to some transit
wrong state in tests (it happens when you run the test, but correct
state show when you put a breakpoint and step into each state
computation).
To solve it, we remove this default value assignment. It should be safe
since this field is not required.

closes odoo/odoo#134264

Related: odoo/enterprise#46875
Signed-off-by: Steve Van Essche <svs@odoo.com>
---
 addons/mrp/models/mrp_production.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py
index b84432739157..916351de78d2 100644
--- a/addons/mrp/models/mrp_production.py
+++ b/addons/mrp/models/mrp_production.py
@@ -569,7 +569,6 @@ class MrpProduction(models.Model):
 
     @api.depends('state', 'move_raw_ids.state')
     def _compute_reservation_state(self):
-        self.reservation_state = False
         for production in self:
             if production.state in ('draft', 'done', 'cancel'):
                 continue
-- 
GitLab