[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:
parent
ad6f4412b8
commit
a2807321b2
@ -59,8 +59,10 @@ class AccountMove(models.Model):
|
|||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
if set(vals).intersection(FIELDS_AFFECTS_ASSET_MOVE):
|
if set(vals).intersection(FIELDS_AFFECTS_ASSET_MOVE):
|
||||||
deprs = self.env["account.asset.line"].search(
|
deprs = (
|
||||||
[("move_id", "in", self.ids), ("type", "=", "depreciate")]
|
self.env["account.asset.line"]
|
||||||
|
.sudo()
|
||||||
|
.search([("move_id", "in", self.ids), ("type", "=", "depreciate")])
|
||||||
)
|
)
|
||||||
if deprs:
|
if deprs:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
|
Loading…
Reference in New Issue
Block a user