From 67d975b94b8080cd895c90d86005bac0d75f2a95 Mon Sep 17 00:00:00 2001 From: adda-odoo Date: Fri, 15 Dec 2023 14:11:06 -0800 Subject: [PATCH] [FIX] delivery: fix cyclic while loop Steps to reproduce --> 1) Have Returns operation return type set to Delivery Order 2) Create an SO -> Deliver with a shipping carrier 3) Return the delivery and re-return with the same shipping carrier (need to manually update this field value) Solution --> Keep track of `next_moves` that have been accessed This PR is basically an extension of https://github.com/odoo/odoo/pull/142942 opw-3588205 closes odoo/odoo#146878 X-original-commit: c4d834fa0e62752d3f25f9a6d2aaadc1ce3ce5a6 Signed-off-by: William Henrotin (whe) --- addons/stock_delivery/models/stock_picking.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/stock_delivery/models/stock_picking.py b/addons/stock_delivery/models/stock_picking.py index 69e770bb3c1..c47bcb599a0 100644 --- a/addons/stock_delivery/models/stock_picking.py +++ b/addons/stock_delivery/models/stock_picking.py @@ -177,10 +177,11 @@ class StockPicking(models.Model): related_pickings |= previous_moves.picking_id previous_moves = previous_moves.move_orig_ids - accessed_moves accessed_moves |= previous_moves - next_moves = self.move_ids.move_dest_ids + accessed_moves = next_moves = self.move_ids.move_dest_ids while next_moves: related_pickings |= next_moves.picking_id - next_moves = next_moves.move_dest_ids + next_moves = next_moves.move_dest_ids - accessed_moves + accessed_moves |= next_moves without_tracking = related_pickings.filtered(lambda p: not p.carrier_tracking_ref) without_tracking.carrier_tracking_ref = res['tracking_number'] for p in related_pickings - without_tracking: