[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
This commit is contained in:
David
2023-03-09 17:29:45 +01:00
parent 07b53eb16a
commit 6d587c1e22

View File

@@ -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