From 17ee121e7eeb187e2b4d8b46c08596ca01fdd2ee Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Thu, 30 Nov 2017 15:29:35 +0100 Subject: [PATCH] [FIX] contract. Fix tests. Do not assume journal. Present tests assume a journal will always already exist. This is not the case in environments where a chart of accounts has not been set up. --- contract/__manifest__.py | 2 +- contract/tests/test_contract.py | 33 +++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/contract/__manifest__.py b/contract/__manifest__.py index 54250c1c..4f55ea07 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -9,7 +9,7 @@ { 'name': 'Contracts Management - Recurring', - 'version': '10.0.4.3.0', + 'version': '10.0.4.3.1', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "OpenERP SA, " diff --git a/contract/tests/test_contract.py b/contract/tests/test_contract.py index 399dcc2c..90305abf 100644 --- a/contract/tests/test_contract.py +++ b/contract/tests/test_contract.py @@ -9,9 +9,30 @@ from odoo.tests import common class TestContractBase(common.SavepointCase): + + post_install = True + at_install = False + @classmethod def setUpClass(cls): super(TestContractBase, cls).setUpClass() + # Make sure a sale journal is present for tests + sequence_model = cls.env['ir.sequence'] + contract_sequence = sequence_model.create({ + 'company_id': cls.env.user.company_id.id, + 'code': 'contract', + 'name': 'contract sequence', + 'number_next': 1, + 'implementation': 'standard', + 'padding': 3, + 'number_increment': 1}) + journal_model = cls.env['account.journal'] + journal_model.create({ + 'company_id': cls.env.user.company_id.id, + 'code': 'contract', + 'name': 'contract journal', + 'sequence_id': contract_sequence.id, + 'type': 'sale'}) cls.partner = cls.env.ref('base.res_partner_2') cls.product = cls.env.ref('product.product_product_2') cls.product.taxes_id += cls.env['account.tax'].search( @@ -286,10 +307,14 @@ class TestContract(TestContractBase): line = self._add_template_line() line.product_id.description_sale = 'Test' line._onchange_product_id() - self.assertEqual(line.name, - '\n'.join([line.product_id.name, - line.product_id.description_sale, - ])) + # Make sure we use same language settings as in tested code: + product = line.product_id.with_context( + lang=self.partner.lang, + partner=self.partner.id) + product_name = product.name_get()[0][1] + self.assertEqual( + line.name, + '\n'.join([product_name, line.product_id.description_sale])) def test_contract_count(self): """It should return contract count."""