mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
performance improvement
This commit is contained in:
committed by
OCA-git-bot
parent
23c8e7dce8
commit
620aaf923a
@@ -115,22 +115,20 @@ class AccountMoveLine(models.Model):
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
# Check if at least one asset is linked to a move
|
||||
linked_asset = False
|
||||
for move in self:
|
||||
linked_asset = move.asset_id
|
||||
if linked_asset:
|
||||
break
|
||||
if (
|
||||
linked_asset and
|
||||
set(vals).intersection(FIELDS_AFFECTS_ASSET_MOVE_LINE) and
|
||||
not (
|
||||
self.env.context.get('allow_asset_removal') and
|
||||
list(vals.keys()) == ['asset_id'])
|
||||
):
|
||||
raise UserError(
|
||||
_("You cannot change an accounting item "
|
||||
"linked to an asset depreciation line."))
|
||||
# Check if at least one asset is linked to a move
|
||||
linked_asset = False
|
||||
for move in self:
|
||||
linked_asset = move.asset_id
|
||||
if linked_asset:
|
||||
raise UserError(
|
||||
_("You cannot change an accounting item "
|
||||
"linked to an asset depreciation line."))
|
||||
if vals.get('asset_id'):
|
||||
raise UserError(
|
||||
_("You are not allowed to link "
|
||||
|
||||
Reference in New Issue
Block a user