summaryrefslogtreecommitdiff
path: root/odoo/addons/test_inherits_depends
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2019-01-09 13:45:02 +0000
committerMartin Trigaux <mat@odoo.com>2019-01-10 15:28:11 +0000
commit73ebe68486bb6892d001f15e9ed4a8bf4aee8766 (patch)
tree1d02d60f572a28a7c956f8fc33978714bce1f2ba /odoo/addons/test_inherits_depends
parentec2263080abba3b5385b13d381e8c934ef8f5657 (diff)
[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 c9837ac5dcb) 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 574f4c3d and c9837ac closes odoo/odoo#30116
Diffstat (limited to 'odoo/addons/test_inherits_depends')
-rw-r--r--odoo/addons/test_inherits_depends/__init__.py3
-rw-r--r--odoo/addons/test_inherits_depends/__manifest__.py12
-rw-r--r--odoo/addons/test_inherits_depends/models.py10
-rw-r--r--odoo/addons/test_inherits_depends/tests/__init__.py3
-rw-r--r--odoo/addons/test_inherits_depends/tests/test_inherits.py29
5 files changed, 57 insertions, 0 deletions
diff --git a/odoo/addons/test_inherits_depends/__init__.py b/odoo/addons/test_inherits_depends/__init__.py
new file mode 100644
index 00000000000..d6210b1285d
--- /dev/null
+++ b/odoo/addons/test_inherits_depends/__init__.py
@@ -0,0 +1,3 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import models
diff --git a/odoo/addons/test_inherits_depends/__manifest__.py b/odoo/addons/test_inherits_depends/__manifest__.py
new file mode 100644
index 00000000000..335fdee1362
--- /dev/null
+++ b/odoo/addons/test_inherits_depends/__manifest__.py
@@ -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,
+}
diff --git a/odoo/addons/test_inherits_depends/models.py b/odoo/addons/test_inherits_depends/models.py
new file mode 100644
index 00000000000..77ad3ad1206
--- /dev/null
+++ b/odoo/addons/test_inherits_depends/models.py
@@ -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()
diff --git a/odoo/addons/test_inherits_depends/tests/__init__.py b/odoo/addons/test_inherits_depends/tests/__init__.py
new file mode 100644
index 00000000000..5a5bb8a95f3
--- /dev/null
+++ b/odoo/addons/test_inherits_depends/tests/__init__.py
@@ -0,0 +1,3 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import test_inherits
diff --git a/odoo/addons/test_inherits_depends/tests/test_inherits.py b/odoo/addons/test_inherits_depends/tests/test_inherits.py
new file mode 100644
index 00000000000..c758b47f8de
--- /dev/null
+++ b/odoo/addons/test_inherits_depends/tests/test_inherits.py
@@ -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')