diff --git a/account_statement_operation_rule/tests/__init__.py b/account_statement_operation_rule/tests/__init__.py index 23fa21ab..5b8ab23a 100644 --- a/account_statement_operation_rule/tests/__init__.py +++ b/account_statement_operation_rule/tests/__init__.py @@ -19,4 +19,4 @@ # ############################################################################## -from . import test_rule +from . import test_rule_rounding diff --git a/account_statement_operation_rule/tests/common.py b/account_statement_operation_rule/tests/common.py index d8cf7d75..6ab6123c 100644 --- a/account_statement_operation_rule/tests/common.py +++ b/account_statement_operation_rule/tests/common.py @@ -20,7 +20,9 @@ ############################################################################## -def prepare_statement(test, difference): +def prepare_statement(test, difference, + statement_line_currency=None, + move_line_currency=None): """ Prepare a bank statement line and a move line The difference is applied on the bank statement line relatively to @@ -35,24 +37,33 @@ def prepare_statement(test, difference): 'name': '/', 'journal_id': test.ref('account.cash_journal') }) - statement_line = statement_line_obj.create({ + line_vals = { 'name': '001', 'amount': amount + difference, 'statement_id': statement.id, - }) + } + if statement_line_currency: + line_vals['currency_id'] = statement_line_currency.id + statement_line = statement_line_obj.create(line_vals) move = move_obj.create({ 'journal_id': test.ref('account.sales_journal') }) - move_line = move_line_obj.create({ + line_vals = { 'move_id': move.id, 'name': '001', 'account_id': test.ref('account.a_recv'), 'debit': amount, - }) - move_line_obj.create({ + } + if move_line_currency: + line_vals['currency_id'] = move_line_currency.id + move_line = move_line_obj.create(line_vals) + line_vals = { 'move_id': move.id, 'name': '001', 'account_id': test.ref('account.a_sale'), 'credit': amount, - }) + } + if move_line_currency: + line_vals['currency_id'] = move_line_currency.id + move_line_obj.create(line_vals) return statement_line, move_line diff --git a/account_statement_operation_rule/tests/test_rule.py b/account_statement_operation_rule/tests/test_rule_rounding.py similarity index 90% rename from account_statement_operation_rule/tests/test_rule.py rename to account_statement_operation_rule/tests/test_rule_rounding.py index 2f6ea990..1a522cd1 100644 --- a/account_statement_operation_rule/tests/test_rule.py +++ b/account_statement_operation_rule/tests/test_rule_rounding.py @@ -19,15 +19,16 @@ # ############################################################################## +import unittest2 from openerp.tests import common from .common import prepare_statement -class TestRule(common.TransactionCase): +class TestRuleRounding(common.TransactionCase): def setUp(self): - super(TestRule, self).setUp() + super(TestRuleRounding, self).setUp() self.operation_obj = self.env['account.statement.operation.template'] self.rule_obj = self.env['account.statement.operation.rule'] self.operation_round_1 = self.operation_obj.create({ @@ -151,3 +152,16 @@ class TestRule(common.TransactionCase): ops = self.rule_obj.operations_for_reconciliation(statement_line.id, move_line.ids) self.assertEquals(ops, self.operation_round_1) + + def test_multicurrency_lines(self): + """No rounding rules on multi-currency lines""" + currency = self.browse_ref('base.AED') + statement_line, move_line = prepare_statement( + self, + -0.5, + statement_line_currency=currency, + move_line_currency=currency + ) + ops = self.rule_obj.operations_for_reconciliation(statement_line.id, + move_line.ids) + self.assertFalse(ops)