Finish 12.0 migration of account_asset_management
* account_asset: Do not loop on all the lines to search for one linked asset Before this change, the use of `mapped` on self did loop on all the move lines that are included in self to get the assets, what could be very costly for a simple write on a lot of move lines. As the goal is to raise an error only if at least one move is linked to an asset, we break the loop if the condition is fulfilled. * performance improvement * [RMV] - Remove useless dependency In 12.0 account_fiscal_year is a standard feature no need to depend on oca module account_fiscal_year
This commit is contained in:
parent
9ff14512da
commit
8fa0de5226
@ -6,7 +6,7 @@
|
|||||||
'version': '12.0.1.0.0',
|
'version': '12.0.1.0.0',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'depends': [
|
'depends': [
|
||||||
'account_fiscal_year',
|
'account',
|
||||||
],
|
],
|
||||||
'excludes': ['account_asset'],
|
'excludes': ['account_asset'],
|
||||||
'author': "Noviat,Odoo Community Association (OCA)",
|
'author': "Noviat,Odoo Community Association (OCA)",
|
||||||
|
@ -116,12 +116,16 @@ class AccountMoveLine(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
if (
|
if (
|
||||||
self.mapped('asset_id') and
|
|
||||||
set(vals).intersection(FIELDS_AFFECTS_ASSET_MOVE_LINE) and
|
set(vals).intersection(FIELDS_AFFECTS_ASSET_MOVE_LINE) and
|
||||||
not (
|
not (
|
||||||
self.env.context.get('allow_asset_removal') and
|
self.env.context.get('allow_asset_removal') and
|
||||||
list(vals.keys()) == ['asset_id'])
|
list(vals.keys()) == ['asset_id'])
|
||||||
):
|
):
|
||||||
|
# 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(
|
raise UserError(
|
||||||
_("You cannot change an accounting item "
|
_("You cannot change an accounting item "
|
||||||
"linked to an asset depreciation line."))
|
"linked to an asset depreciation line."))
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
|
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||||
<title>Assets Management</title>
|
<title>Assets Management</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user