From c0adc624b51a8bfadea3092fbca96bc3e319ac0f Mon Sep 17 00:00:00 2001 From: Quentin De Paoli Date: Mon, 7 Sep 2009 18:40:12 +0200 Subject: [PATCH] [FIX] multi currency reconciliations on bank statements weren't properly displayed [FIX] multi currency payments weren't correctly computed on invoice's residual amount bzr revid: qdp@cyan-20090907164012-eufzzqls4gqlkbv6 --- addons/account/account_bank_statement.py | 17 ++++++++++++++++- addons/account/account_invoice_view.xml | 4 ++++ addons/account/invoice.py | 5 ++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 0f6aca2f917..56c4ddba96e 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -213,6 +213,11 @@ class account_bank_statement(osv.osv): amount = res_currency_obj.compute(cr, uid, st.currency.id, company_currency_id, move.amount, context=context, account=acc_cur) + if st.currency.id <> company_currency_id: + amount_cur = res_currency_obj.compute(cr, uid, company_currency_id, + st.currency.id, amount, context=context, + account=acc_cur) + val['amount_currency'] = -amount_cur if move.account_id and move.account_id.currency_id and move.account_id.currency_id.id <> company_currency_id: val['currency_id'] = move.account_id.currency_id.id @@ -430,7 +435,17 @@ class account_bank_statement_reconcile(osv.osv): def name_get(self, cursor, user, ids, context=None): res= [] for o in self.browse(cursor, user, ids, context=context): - res.append((o.id, '[%.2f]' % (o.total_entry - o.total_new,))) + result = 0.0 + res_currency = '' + for line in o.line_ids: + if line.amount_currency and line.currency_id: + result += line.amount_currency + res_currency = line.currency_id.code + else: + result += line.debit - line.credit + if res_currency: + res_currency = ' ' + res_currency + res.append((o.id, '[%.2f'% (result - o.total_new,) + res_currency + ']' )) return res _columns = { diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 5b06a40acb1..6d14f25427c 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -221,6 +221,8 @@ + + @@ -306,6 +308,8 @@ + + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index df71775b59b..ad38ff87e68 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -107,7 +107,10 @@ class account_invoice(osv.osv): paid_amt = 0.0 to_pay = inv.amount_total for lines in inv.move_lines: - paid_amt = paid_amt - lines.credit + lines.debit + if lines.amount_currency and lines.currency_id: + paid_amt += lines.amount_currency + else: + paid_amt += lines.credit + lines.debit res[inv.id] = round(to_pay - abs(paid_amt),int(config['price_accuracy'])) return res