From 2e747da2532911db8b4f44682779329cd8d00b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Mon, 22 Jul 2024 14:10:28 +0200 Subject: [PATCH] [FIX] rma_sale: Avoid rma access error when cancel a sales order or change to draft an invoice. Use case: - User with permission in sales but not in RMA. - Cancel sales order or change to draft a linked invoice TT50260 --- rma_sale/models/account_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rma_sale/models/account_move.py b/rma_sale/models/account_move.py index 3048289a..2b46c48f 100644 --- a/rma_sale/models/account_move.py +++ b/rma_sale/models/account_move.py @@ -11,14 +11,14 @@ class AccountMove(models.Model): """If this a refund linked to an RMA, undo the linking of the reception move for having proper quantities and status. """ - for rma in self.env["rma"].search([("refund_id", "in", self.ids)]): + for rma in self.env["rma"].sudo().search([("refund_id", "in", self.ids)]): if rma.sale_line_id: rma._unlink_refund_with_reception_move() return super().button_cancel() def button_draft(self): """Relink the reception move when passing the refund again to draft.""" - for rma in self.env["rma"].search([("refund_id", "in", self.ids)]): + for rma in self.env["rma"].sudo().search([("refund_id", "in", self.ids)]): if rma.sale_line_id: rma._link_refund_with_reception_move() return super().button_draft()