From bc904a08dc722d6b7c558c53c2fd4cbfb6509a0e Mon Sep 17 00:00:00 2001 From: David Date: Wed, 26 Oct 2022 12:20:15 +0200 Subject: [PATCH] [FIX] rma: multiple substitution moves The product replacement could explode into several moves like in the case of MRP BoM kits. TT40194 --- rma/models/rma.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/rma/models/rma.py b/rma/models/rma.py index 76c0901c..1e1d8827 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -1134,11 +1134,14 @@ class Rma(models.Model): self._ensure_can_be_replaced() moves_before = self.delivery_move_ids self._action_launch_stock_rule(scheduled_date, warehouse, product, qty, uom) - new_move = self.delivery_move_ids - moves_before - if new_move: - self.reception_move_id.move_dest_ids = [(4, new_move.id)] - self.message_post( - body=_( + new_moves = self.delivery_move_ids - moves_before + self.reception_move_id.move_dest_ids += new_moves + body = "" + # The product replacement could explode into several moves like in the case of + # MRP BoM Kits + for new_move in new_moves: + body += ( + _( "Replacement: " 'Move %s (Picking " - 'Product %s
' - "Quantity %f %s
" - "This replacement did not create a new move, but one of " - "the previously created moves was updated with this data." - ) - % (product.id, product.display_name, qty, uom.name) + self.message_post( + body=body + or _( + "Replacement:
" + 'Product %s
' + "Quantity %f %s
" + "This replacement did not create a new move, but one of " + "the previously created moves was updated with this data." ) + % (product.id, product.display_name, qty, uom.name) + ) if self.state != "waiting_replacement": self.state = "waiting_replacement"