mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[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
This commit is contained in:
@@ -43,8 +43,12 @@ class AccountMove(models.Model):
|
||||
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user