From 176ee25f1ed8084ccfb9bd26ca4cffd4c39110f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Tue, 16 Dec 2014 19:01:07 +0100 Subject: [PATCH] [IMP] account_asset_management: support moves with more than one asset depreciaion in the same move Such moves are not generated by the module itself but may exist when importing existing moves from another system. This patch should otherwise not change the behaviour of the module. --- account_asset_management/account_asset.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/account_asset_management/account_asset.py b/account_asset_management/account_asset.py index f2f585689..53a4a7f18 100644 --- a/account_asset_management/account_asset.py +++ b/account_asset_management/account_asset.py @@ -715,7 +715,7 @@ class account_asset_asset(orm.Model): CASE WHEN (aadl.type = 'depreciate' AND aadl.init_entry = TRUE) THEN aadl.amount - WHEN aml.account_id=%s + WHEN aml.account_id=%s AND aml.asset_id=%s THEN (COALESCE(aml.debit,0.0) - COALESCE(aml.credit,0.0)) ELSE 0.0 END AS amount @@ -725,7 +725,8 @@ class account_asset_asset(orm.Model): ON aml.move_id=am.id WHERE aadl.id IN %s) sq """, - (exp_acc_id, tuple(posted_depreciation_line_ids))) + (exp_acc_id, asset.id, + tuple(posted_depreciation_line_ids))) res = cr.fetchone() depreciated_value = res[0] residual_amount = asset.asset_value - depreciated_value @@ -741,10 +742,13 @@ class account_asset_asset(orm.Model): INNER JOIN account_move am ON aadl.move_id=am.id INNER JOIN account_move_line aml ON aml.move_id=am.id INNER JOIN account_period ap ON am.period_id=ap.id - WHERE aadl.id in %s AND aml.account_id=%s AND ap.fiscalyear_id=%s + WHERE aadl.id in %s + AND aml.account_id=%s AND aml.asset_id=%s + AND ap.fiscalyear_id=%s """, (tuple(posted_depreciation_line_ids), - exp_acc_id, entry['fy_id'])) + exp_acc_id, asset.id, + entry['fy_id'])) res = cr.fetchone() fy_amount_check = res[0] else: