[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 (cfc9837ac5dc) 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 at574f4c3dandc9837accloses odoo/odoo#30116
This commit is contained in:
@@ -26,3 +26,14 @@ class test_inherits(common.TransactionCase):
|
||||
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')
|
||||
Reference in New Issue
Block a user