Permalink
Browse files

[ADD] test_inherits_depends: new test module

This commit adds a test to test the scenario fixed in the parent commit.

Creating a new test module is necessary as the bug is only revealed when the
current module is different than the model._original_module (cf c9837ac)

Before that commit, was failing only the second search of
test_ir_model_data_inherits_depends.
Add other test to avoid regression of the bugs corrected at 574f4c3 and c9837ac

closes #30116
  • Loading branch information...
mart-e committed Jan 9, 2019
1 parent ec22630 commit 73ebe68486bb6892d001f15e9ed4a8bf4aee8766
@@ -26,3 +26,14 @@ def test_write_3_levels_inherits(self):
pallet = self.env.ref('test_inherits.pallet_a')
pallet.write({'name': 'C'})
self.assertEqual(pallet.name, 'C')

def test_ir_model_data_inherits(self):
""" Check the existence of the correct ir.model.data """
IrModelData = self.env['ir.model.data']
field = IrModelData.search([('name', '=', 'field_test_unit__name')])
self.assertEqual(len(field), 1)
self.assertEqual(field.module, 'test_inherits')

field = IrModelData.search([('name', '=', 'field_test_box__name')])
self.assertEqual(len(field), 1)
self.assertEqual(field.module, 'test_inherits')
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import models
@@ -0,0 +1,12 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
'name': 'test-inherits-depends',
'version': '0.1',
'category': 'Tests',
'description': """A module to verify the inheritance using _inherits in non-original modules.""",
'depends': ['test_inherits'],
'data': [],
'installable': True,
'auto_install': False,
}
@@ -0,0 +1,10 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import models, fields


# We add a field on this model
class Unit(models.Model):
_inherit = 'test.unit'

second_name = fields.Char()
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import test_inherits
@@ -0,0 +1,29 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo.tests import common


class test_inherits(common.TransactionCase):

def test_ir_model_data_inherits_again(self):
""" Re-run test_inherits test to make sure another imd hasn't been created """
IrModelData = self.env['ir.model.data']
field = IrModelData.search([('name', '=', 'field_test_unit__name')])
self.assertEqual(len(field), 1)
self.assertEqual(field.module, 'test_inherits')

field = IrModelData.search([('name', '=', 'field_test_box__name')])
self.assertEqual(len(field), 1)
self.assertEqual(field.module, 'test_inherits')


def test_ir_model_data_inherits_depends(self):
""" Check the existence of the correct ir.model.data """
IrModelData = self.env['ir.model.data']
field = IrModelData.search([('name', '=', 'field_test_unit__second_name')])
self.assertEqual(len(field), 1)
self.assertEqual(field.module, 'test_inherits_depends')

field = IrModelData.search([('name', '=', 'field_test_box__second_name')])
self.assertEqual(len(field), 1)
self.assertEqual(field.module, 'test_inherits_depends')

0 comments on commit 73ebe68

Please sign in to comment.