Included PR #828 Fix computation of depreciation lines when having multiple assets in invoice
This commit is contained in:
parent
08907b0b1d
commit
9ff14512da
@ -72,19 +72,26 @@ class AccountAssetLine(models.Model):
|
||||
dlines = dlines.filtered(lambda l: l.type == 'depreciate')
|
||||
dlines = dlines.sorted(key=lambda l: l.line_date)
|
||||
|
||||
for i, dl in enumerate(dlines):
|
||||
if i == 0:
|
||||
depreciation_base = dl.depreciation_base
|
||||
depreciated_value = dl.previous_id \
|
||||
and (depreciation_base - dl.previous_id.remaining_value) \
|
||||
or 0.0
|
||||
remaining_value = \
|
||||
depreciation_base - depreciated_value - dl.amount
|
||||
else:
|
||||
depreciated_value += dl.previous_id.amount
|
||||
remaining_value -= dl.amount
|
||||
dl.depreciated_value = depreciated_value
|
||||
dl.remaining_value = remaining_value
|
||||
# Group depreciation lines per asset
|
||||
asset_ids = dlines.mapped('asset_id')
|
||||
grouped_dlines = []
|
||||
for asset in asset_ids:
|
||||
grouped_dlines.append(
|
||||
dlines.filtered(lambda l: l.asset_id.id == asset.id))
|
||||
|
||||
for dlines in grouped_dlines:
|
||||
for i, dl in enumerate(dlines):
|
||||
if i == 0:
|
||||
depreciation_base = dl.depreciation_base
|
||||
tmp = depreciation_base - dl.previous_id.remaining_value
|
||||
depreciated_value = dl.previous_id and tmp or 0.0
|
||||
remaining_value = \
|
||||
depreciation_base - depreciated_value - dl.amount
|
||||
else:
|
||||
depreciated_value += dl.previous_id.amount
|
||||
remaining_value -= dl.amount
|
||||
dl.depreciated_value = depreciated_value
|
||||
dl.remaining_value = remaining_value
|
||||
|
||||
@api.depends('move_id')
|
||||
@api.multi
|
||||
|
@ -5,4 +5,5 @@
|
||||
- Stéphane Bidoul (Acsone)
|
||||
- Adrien Peiffer (Acsone)
|
||||
- Akim Juillerat <akim.juillerat@camptocamp.com>
|
||||
- Henrik Norlin (Apps2GROW)
|
||||
- Henrik Norlin (Apps2GROW)
|
||||
- Maxence Groine <mgroine@fiefmanage.ch>
|
||||
|
@ -101,7 +101,7 @@ class TestAssetManagement(SavepointCase):
|
||||
'account_id': cls.account_payable.id,
|
||||
'price_unit': 20000.00,
|
||||
'quantity': 1,
|
||||
'product_id': cls.product_id})
|
||||
'product_id': cls.product.id})
|
||||
|
||||
cls.invoice_2 = cls.account_invoice.create({
|
||||
'partner_id': cls.partner.id,
|
||||
|
Loading…
Reference in New Issue
Block a user