From b2385d6b9e9185ca2274c9763e7808cb13b73fdd Mon Sep 17 00:00:00 2001 From: Arthur Maniet Date: Fri, 12 Sep 2014 12:01:25 +0200 Subject: [PATCH] [FIX]: account: reconciliation: handling negative amount_residual --- addons/account/account_move_line.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index a3e224cd80d..1918b5401d7 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -794,19 +794,29 @@ class account_move_line(osv.osv): 'partial_reconciliation_siblings_ids': partial_reconciliation_siblings_ids, } + # Amount residual can be negative + debit = line.debit + credit = line.credit + amount_residual = line.amount_residual + amount_residual_currency = line.amount_residual_currency + if line.amount_residual < 0: + debit, credit = credit, debit + amount_residual = -amount_residual + amount_residual_currency = -amount_residual_currency + # Get right debit / credit: line_currency = line.currency_id or company_currency amount_currency_str = "" if line.currency_id and line.amount_currency: amount_currency_str = rml_parser.formatLang(line.amount_currency, currency_obj=line.currency_id) if target_currency and line_currency == target_currency and target_currency != company_currency: - debit = line.debit > 0 and line.amount_residual_currency or 0.0 - credit = line.credit > 0 and line.amount_residual_currency or 0.0 - amount_currency_str = rml_parser.formatLang(line.amount_residual, currency_obj=company_currency) + debit = debit > 0 and amount_residual_currency or 0.0 + credit = credit > 0 and amount_residual_currency or 0.0 + amount_currency_str = amount_residual_currency(amount_residual, currency_obj=company_currency) amount_str = rml_parser.formatLang(debit or credit, currency_obj=target_currency) else: - debit = line.debit > 0 and line.amount_residual or 0.0 - credit = line.credit > 0 and line.amount_residual or 0.0 + debit = debit > 0 and amount_residual or 0.0 + credit = credit > 0 and amount_residual or 0.0 amount_str = rml_parser.formatLang(debit or credit, currency_obj=company_currency) if target_currency and target_currency != company_currency: amount_currency_str = rml_parser.formatLang(debit or credit, currency_obj=line_currency) @@ -817,12 +827,6 @@ class account_move_line(osv.osv): credit = currency_obj.compute(cr, uid, target_currency.id, company_currency.id, credit, context=ctx) amount_str = rml_parser.formatLang(debit or credit, currency_obj=target_currency) - # Amount residual can be negative - if debit < 0: - debit, credit = credit, -debit - if credit < 0: - debit, credit = -credit, debit - ret_line['credit'] = credit ret_line['debit'] = debit ret_line['amount_str'] = amount_str