From fc6d98df2427153050dd4386431cc24a023e2e2d Mon Sep 17 00:00:00 2001 From: Toufik Benjaa Date: Wed, 11 Apr 2018 11:19:19 +0200 Subject: [PATCH] [FIX] account_asset: Allow accountant to validate invoices - When validating an invoice, the create method of the model account.asset.asset is called. Accountant have the access rights to create account.asset.asset object, but they do not have the rights to write on them. The issue here is that the create of the account.asset.asset is done, but right after a right is done in the same object, which trigger an AccessError. To fix this issue, we make the write using the admin env. This doesn't cause security issues since the user needs the create accesses. OPW-1832797 --- addons/account_asset/models/account_asset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_asset/models/account_asset.py b/addons/account_asset/models/account_asset.py index 188ea8f5d16..fe263cf608b 100644 --- a/addons/account_asset/models/account_asset.py +++ b/addons/account_asset/models/account_asset.py @@ -411,7 +411,7 @@ class AccountAssetAsset(models.Model): @api.model def create(self, vals): asset = super(AccountAssetAsset, self.with_context(mail_create_nolog=True)).create(vals) - asset.compute_depreciation_board() + asset.sudo().compute_depreciation_board() return asset @api.multi