[FIX] account: Improve balance computation of bank statement for multicurrency(case...
authorpso (OpenERP) <pso@tinyerp.com>
Mon, 19 Sep 2011 12:19:30 +0000 (17:49 +0530)
committerpso (OpenERP) <pso@tinyerp.com>
Mon, 19 Sep 2011 12:19:30 +0000 (17:49 +0530)
bzr revid: pso@tinyerp.com-20110919121930-memr324q17tp6vch

addons/account/account_bank_statement.py

index b6ff2c4..7c419fd 100644 (file)
@@ -57,18 +57,19 @@ class account_bank_statement(osv.osv):
             res[statement.id] = statement.balance_start
             currency_id = statement.currency.id
             for line in statement.move_line_ids:
-                if line.debit > 0:
-                    if line.account_id.id == \
-                            statement.journal_id.default_debit_account_id.id:
-                        res[statement.id] += res_currency_obj.compute(cursor,
-                                user, company_currency_id, currency_id,
-                                line.debit, context=context)
+                if currency_id == company_currency_id:
+                    if line.debit > 0:
+                        if line.account_id.id == \
+                                statement.journal_id.default_debit_account_id.id:
+                            res[statement.id] += line.debit
+                    else:
+                        if line.account_id.id == \
+                                statement.journal_id.default_credit_account_id.id:
+                            res[statement.id] -= line.credit
                 else:
-                    if line.account_id.id == \
-                            statement.journal_id.default_credit_account_id.id:
-                        res[statement.id] -= res_currency_obj.compute(cursor,
-                                user, company_currency_id, currency_id,
-                                line.credit, context=context)
+                    if line.amount_currency > 0:
+                        res[statement.id] += line.amount_currency
+
             if statement.state == 'draft':
                 for line in statement.line_ids:
                     res[statement.id] += line.amount