From 1640e5af0bedb3a53d5964dc61aed07a2df4368c Mon Sep 17 00:00:00 2001 From: David Date: Thu, 9 Mar 2023 17:29:45 +0100 Subject: [PATCH] [FIX] rma: avoid reopening a cancelled RMA when the reception is deleted When we delete the reception for an RMA, we're setting it to draft automatically so we can confirm it again and create a new reception. This is unconvenient when the RMA is cancelled, as we don't wan't to reopen it automatically. TT41943 --- rma/__manifest__.py | 2 +- rma/models/stock_move.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rma/__manifest__.py b/rma/__manifest__.py index 4f85e032..e3ff4ba9 100644 --- a/rma/__manifest__.py +++ b/rma/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Return Merchandise Authorization Management", "summary": "Return Merchandise Authorization (RMA)", - "version": "15.0.1.1.1", + "version": "15.0.1.1.2", "development_status": "Production/Stable", "category": "RMA", "website": "https://github.com/OCA/rma", diff --git a/rma/models/stock_move.py b/rma/models/stock_move.py index 1e846eec..8d992561 100644 --- a/rma/models/stock_move.py +++ b/rma/models/stock_move.py @@ -35,7 +35,9 @@ class StockMove(models.Model): rma_receiver = self.sudo().mapped("rma_receiver_ids") rma = self.sudo().mapped("rma_id") res = super().unlink() - rma_receiver.write({"state": "draft"}) + rma_receiver.filtered(lambda x: x.state != "cancelled").write( + {"state": "draft"} + ) rma.update_received_state() rma.update_replaced_state() return res