From aa30b2173e71ecc68a9b8e0242b638b3c8c0c2a1 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 18 Jun 2024 20:50:59 +0200 Subject: [PATCH] [FIX] account_asset_management: Allow to unlink w/o billing permission Some users may be allowed to unlink invoices without billing access, but with current code, they are not able, as the asset line check is done without sudo, and other users except billing or higher ones aren't allowed to access to that model. TT49673 --- account_asset_management/models/account_move.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/account_asset_management/models/account_move.py b/account_asset_management/models/account_move.py index 817045fef09..34e2c927ef7 100644 --- a/account_asset_management/models/account_move.py +++ b/account_asset_management/models/account_move.py @@ -42,8 +42,12 @@ def _compute_asset_count(self): def unlink(self): # for move in self: - deprs = self.env["account.asset.line"].search( - [("move_id", "in", self.ids), ("type", "in", ["depreciate", "remove"])] + deprs = ( + self.env["account.asset.line"] + .sudo() + .search( + [("move_id", "in", self.ids), ("type", "in", ["depreciate", "remove"])] + ) ) if deprs and not self.env.context.get("unlink_from_asset"): raise UserError(