Add test: check if rounding rules are well skipped on multi-currency lines

This commit is contained in:
Guewen Baconnier
2014-11-26 10:43:54 +01:00
committed by Cyril Gaudin
parent 585416d7f8
commit fd2430747e
3 changed files with 35 additions and 10 deletions

View File

@@ -19,4 +19,4 @@
# #
############################################################################## ##############################################################################
from . import test_rule from . import test_rule_rounding

View File

@@ -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 """ Prepare a bank statement line and a move line
The difference is applied on the bank statement line relatively to The difference is applied on the bank statement line relatively to
@@ -35,24 +37,33 @@ def prepare_statement(test, difference):
'name': '/', 'name': '/',
'journal_id': test.ref('account.cash_journal') 'journal_id': test.ref('account.cash_journal')
}) })
statement_line = statement_line_obj.create({ line_vals = {
'name': '001', 'name': '001',
'amount': amount + difference, 'amount': amount + difference,
'statement_id': statement.id, '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({ move = move_obj.create({
'journal_id': test.ref('account.sales_journal') 'journal_id': test.ref('account.sales_journal')
}) })
move_line = move_line_obj.create({ line_vals = {
'move_id': move.id, 'move_id': move.id,
'name': '001', 'name': '001',
'account_id': test.ref('account.a_recv'), 'account_id': test.ref('account.a_recv'),
'debit': amount, '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, 'move_id': move.id,
'name': '001', 'name': '001',
'account_id': test.ref('account.a_sale'), 'account_id': test.ref('account.a_sale'),
'credit': amount, '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 return statement_line, move_line

View File

@@ -19,15 +19,16 @@
# #
############################################################################## ##############################################################################
import unittest2
from openerp.tests import common from openerp.tests import common
from .common import prepare_statement from .common import prepare_statement
class TestRule(common.TransactionCase): class TestRuleRounding(common.TransactionCase):
def setUp(self): def setUp(self):
super(TestRule, self).setUp() super(TestRuleRounding, self).setUp()
self.operation_obj = self.env['account.statement.operation.template'] self.operation_obj = self.env['account.statement.operation.template']
self.rule_obj = self.env['account.statement.operation.rule'] self.rule_obj = self.env['account.statement.operation.rule']
self.operation_round_1 = self.operation_obj.create({ 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, ops = self.rule_obj.operations_for_reconciliation(statement_line.id,
move_line.ids) move_line.ids)
self.assertEquals(ops, self.operation_round_1) 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)