From 531401c1ec8baca59988443e4dc5eb93896c0959 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 9 Mar 2023 17:03:01 +0100 Subject: [PATCH] [FIX] rma_sale_mrp: avoid reopening of kit RMAs As we rely on the kit_qty field have the kit/component relation an that's computed when the RMA is created, we want to avoid reopening the RMA to avoid inconsitencies. The user should create a new RMA. TT41943 --- rma_sale_mrp/models/rma.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rma_sale_mrp/models/rma.py b/rma_sale_mrp/models/rma.py index 870c3fbb..97f2e661 100644 --- a/rma_sale_mrp/models/rma.py +++ b/rma_sale_mrp/models/rma.py @@ -64,3 +64,13 @@ class Rma(models.Model): "state": "refunded", } ) + + def action_draft(self): + if self.filtered(lambda r: r.state == "cancelled" and r.phantom_bom_product): + raise UserError( + _( + "To avoid kit quantities inconsistencies it is not possible to convert " + "to draft a cancelled RMA. You should do a new one from the sales order." + ) + ) + return super().action_draft()