[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) <whe@odoo.com>
This commit is contained in:
adda-odoo
2023-12-20 08:35:46 +00:00
parent 6fe45e648d
commit 67d975b94b
@@ -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: