Skip to content
Snippets Groups Projects
Commit 9e31843d authored by Christophe Simonis's avatar Christophe Simonis
Browse files

[FIX] account_asset: correct dependencies of `amount_residual` field

Also use a `set()` to avoid processing assets multiple times when
creating moves from lines
parent 2f374c4c
No related branches found
No related tags found
No related merge requests found
......@@ -228,7 +228,7 @@ class AccountAssetAsset(models.Model):
self.write({'state': 'draft'})
@api.one
@api.depends('value', 'salvage_value', 'depreciation_line_ids')
@api.depends('value', 'salvage_value', 'depreciation_line_ids.move_check', 'depreciation_line_ids.amount')
def _amount_residual(self):
total_amount = 0.0
for line in self.depreciation_line_ids:
......@@ -347,7 +347,7 @@ class AccountAssetDepreciationLine(models.Model):
@api.multi
def create_move(self):
created_move_ids = []
asset_ids = []
asset_ids = set()
for line in self:
depreciation_date = self.env.context.get('depreciation_date') or line.depreciation_date or fields.Date.context_today(self)
periods = self.env['account.period'].find(depreciation_date)
......@@ -404,7 +404,7 @@ class AccountAssetDepreciationLine(models.Model):
})
line.write({'move_id': move.id, 'move_check': True})
created_move_ids.append(move.id)
asset_ids.append(line.asset_id)
asset_ids.add(line.asset_id)
partner_name = line.asset_id.partner_id.name
currency_name = line.asset_id.currency_id.name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment