Browse Source

[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.
pull/178/head
Ronald Portier 7 years ago
parent
commit
17ee121e7e
  1. 2
      contract/__manifest__.py
  2. 33
      contract/tests/test_contract.py

2
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, "

33
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."""

Loading…
Cancel
Save