2
0

[FIX] account_asset_management: Allow to write on moves with no asset permission

Steps to reproduce the problem:

- User (Not accountant) create an invoice.
- Create invoice plan with Deposit on 1st Invoice
- Confirm Order > Register Deposit > Create and View bills
- It throws a permission error

That's because the search on asset lines is done always for each write on the account.move
if certain fields (like the date) are written.
This commit is contained in:
Saran440 2022-06-30 11:16:46 +07:00
parent ad6f4412b8
commit a2807321b2

View File

@ -59,8 +59,10 @@ class AccountMove(models.Model):
def write(self, vals):
if set(vals).intersection(FIELDS_AFFECTS_ASSET_MOVE):
deprs = self.env["account.asset.line"].search(
[("move_id", "in", self.ids), ("type", "=", "depreciate")]
deprs = (
self.env["account.asset.line"]
.sudo()
.search([("move_id", "in", self.ids), ("type", "=", "depreciate")])
)
if deprs:
raise UserError(