diff options
| author | Raphael Collet <rco@odoo.com> | 2020-04-02 06:45:54 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-04-03 11:40:29 +0000 |
| commit | 9afce4805fc8bac45fdba817488aa867fddff69b (patch) | |
| tree | 665f109f3f9881b7e2e0d56caf1a7d9e5aaf9219 /odoo/addons/test_new_api | |
| parent | 6eb7d5c6a07f678e1d1adca7137652e0626ea17e (diff) | |
[IMP] core: reflect models, fields and selections in batch
This saves 4.5% of the total installation time.
X-original-commit: 8519064dce975af542ccd30dc14c56b9bb36d07b
Diffstat (limited to 'odoo/addons/test_new_api')
| -rw-r--r-- | odoo/addons/test_new_api/tests/test_schema.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/odoo/addons/test_new_api/tests/test_schema.py b/odoo/addons/test_new_api/tests/test_schema.py index d8849dd22f6..4404a9da2cb 100644 --- a/odoo/addons/test_new_api/tests/test_schema.py +++ b/odoo/addons/test_new_api/tests/test_schema.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from odoo.models import MetaModel from odoo.tests import common +from odoo.addons.base.models.ir_model import model_xmlid, field_xmlid, selection_xmlid def get_model_name(cls): @@ -14,6 +15,21 @@ def get_model_name(cls): class TestReflection(common.TransactionCase): """ Test the reflection into 'ir.model', 'ir.model.fields', etc. """ + def assertModelXID(self, record): + """ Check the XML id of the given 'ir.model' record. """ + xid = model_xmlid('test_new_api', record.model) + self.assertEqual(record, self.env.ref(xid)) + + def assertFieldXID(self, record): + """ Check the XML id of the given 'ir.model.fields' record. """ + xid = field_xmlid('test_new_api', record.model, record.name) + self.assertEqual(record, self.env.ref(xid)) + + def assertSelectionXID(self, record): + """ Check the XML id of the given 'ir.model.fields.selection' record. """ + xid = selection_xmlid('test_new_api', record.field_id.model, record.field_id.name, record.value) + self.assertEqual(record, self.env.ref(xid)) + def test_models_fields(self): """ check that all models and fields are reflected as expected. """ # retrieve the models defined in this module, and check them @@ -26,6 +42,7 @@ class TestReflection(common.TransactionCase): for ir_model in ir_models: with self.subTest(model=ir_model.model): model = self.env[ir_model.model] + self.assertModelXID(ir_model) self.assertEqual(ir_model.name, model._description or False) self.assertEqual(ir_model.state, 'manual' if model._custom else 'base') self.assertEqual(ir_model.transient, bool(model._transient)) @@ -33,6 +50,7 @@ class TestReflection(common.TransactionCase): for ir_field in ir_model.field_id: with self.subTest(field=ir_field.name): field = model._fields[ir_field.name] + self.assertFieldXID(ir_field) self.assertEqual(ir_field.model, field.model_name) self.assertEqual(ir_field.field_description, field.string) self.assertEqual(ir_field.help, field.help or False) @@ -63,6 +81,8 @@ class TestReflection(common.TransactionCase): self.assertEqual(selection, field.selection) else: self.assertEqual(selection, []) + for sel in ir_field.selection_ids: + self.assertSelectionXID(sel) field_description = field.get_description(self.env) if field.type in ('many2many', 'one2many'): |
