Included PR #828 Fix computation of depreciation lines when having multiple assets in invoice
This commit is contained in:
parent
08907b0b1d
commit
9ff14512da
@ -72,12 +72,19 @@ class AccountAssetLine(models.Model):
|
|||||||
dlines = dlines.filtered(lambda l: l.type == 'depreciate')
|
dlines = dlines.filtered(lambda l: l.type == 'depreciate')
|
||||||
dlines = dlines.sorted(key=lambda l: l.line_date)
|
dlines = dlines.sorted(key=lambda l: l.line_date)
|
||||||
|
|
||||||
|
# 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):
|
for i, dl in enumerate(dlines):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
depreciation_base = dl.depreciation_base
|
depreciation_base = dl.depreciation_base
|
||||||
depreciated_value = dl.previous_id \
|
tmp = depreciation_base - dl.previous_id.remaining_value
|
||||||
and (depreciation_base - dl.previous_id.remaining_value) \
|
depreciated_value = dl.previous_id and tmp or 0.0
|
||||||
or 0.0
|
|
||||||
remaining_value = \
|
remaining_value = \
|
||||||
depreciation_base - depreciated_value - dl.amount
|
depreciation_base - depreciated_value - dl.amount
|
||||||
else:
|
else:
|
||||||
|
@ -6,3 +6,4 @@
|
|||||||
- Adrien Peiffer (Acsone)
|
- Adrien Peiffer (Acsone)
|
||||||
- Akim Juillerat <akim.juillerat@camptocamp.com>
|
- 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,
|
'account_id': cls.account_payable.id,
|
||||||
'price_unit': 20000.00,
|
'price_unit': 20000.00,
|
||||||
'quantity': 1,
|
'quantity': 1,
|
||||||
'product_id': cls.product_id})
|
'product_id': cls.product.id})
|
||||||
|
|
||||||
cls.invoice_2 = cls.account_invoice.create({
|
cls.invoice_2 = cls.account_invoice.create({
|
||||||
'partner_id': cls.partner.id,
|
'partner_id': cls.partner.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user