Merge PR #838 into 11.0

Signed-off-by sbidoul
This commit is contained in:
OCA-git-bot
2019-06-19 15:49:12 +00:00
3 changed files with 12 additions and 8 deletions

View File

@@ -3,7 +3,7 @@
{
'name': 'Assets Management',
'version': '11.0.1.0.0',
'version': '11.0.1.0.1',
'license': 'AGPL-3',
'depends': [
'account_fiscal_year',

View File

@@ -1005,7 +1005,7 @@ msgid "This amount represent the initial value of the asset.\n"
msgstr ""
#. module: account_asset_management
#: code:addons/account_asset_management/models/account_move.py:135
#: code:addons/account_asset_management/models/account_move.py:139
#, python-format
msgid "This option should only be used for a single id at a time."
msgstr ""
@@ -1070,7 +1070,7 @@ msgstr ""
#. module: account_asset_management
#: code:addons/account_asset_management/models/account_move.py:69
#: code:addons/account_asset_management/models/account_move.py:130
#: code:addons/account_asset_management/models/account_move.py:134
#, python-format
msgid "You are not allowed to link an accounting entry to an asset.\n"
"You should generate such entries from the asset."
@@ -1109,7 +1109,7 @@ msgid "You cannot change an accounting entry linked to an asset depreciation lin
msgstr ""
#. module: account_asset_management
#: code:addons/account_asset_management/models/account_move.py:126
#: code:addons/account_asset_management/models/account_move.py:130
#, python-format
msgid "You cannot change an accounting item linked to an asset depreciation line."
msgstr ""

View File

@@ -116,15 +116,19 @@ class AccountMoveLine(models.Model):
@api.multi
def write(self, vals):
if (
self.mapped('asset_id') 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 "