From b2017fd3665ed2e96e9ea581c7d000894e74c333 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Thu, 5 Nov 2020 11:30:56 +0000 Subject: [PATCH] [FIX] stock: apply push rule after transparent rule Usecase to reproduce: - Rule from WH/A -> WH/B as automatique no step added - Rule from WH/B -> WH/C as transfer created Do a move that goes to WH/A and confirm it. It's destination location is correctly set to WH/B but the internal transfer from WH/B to WH/C is not created. It's due to the avoid loop location that returns always true due to code removed in commit 1d36fb428f3dedfc343075c8b4f1980ec3f12600 closes odoo/odoo#61488 X-original-commit: b2a07e4d08beff360ac1e6c95d240a15b1081855 Signed-off-by: Arnold Moyaux --- addons/stock/models/stock_rule.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_rule.py b/addons/stock/models/stock_rule.py index 0ba946d9a5e..b76d722255a 100644 --- a/addons/stock/models/stock_rule.py +++ b/addons/stock/models/stock_rule.py @@ -166,9 +166,10 @@ class StockRule(models.Model): """ new_date = fields.Datetime.to_string(move.date + relativedelta(days=self.delay)) if self.auto == 'transparent': + old_dest_location = move.location_dest_id move.write({'date': new_date, 'location_dest_id': self.location_id.id}) # avoid looping if a push rule is not well configured; otherwise call again push_apply to see if a next step is defined - if self.location_id != move.location_dest_id: + if self.location_id != old_dest_location: # TDE FIXME: should probably be done in the move model IMO move._push_apply() else: