diff options
| author | Raphael Collet <rco@odoo.com> | 2020-04-02 13:11:51 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-04-02 23:54:32 +0000 |
| commit | 46b7fb598498dfe8673268e82944488b741f5caa (patch) | |
| tree | 94d9289051fe5bf8dd1f5d3a4639ec749b6b7d0f /odoo | |
| parent | 0f7d670434cd51e8f19609acd5f8bfae020575ea (diff) | |
[FIX] core: do not register classes when `_module` is falsy
The goal is to avoid a class from being added in the dictionary
`MetaModel.module_to_models`.
We use this feature in tests to prevent classes extending models from
triggering bugs when reloading the registry (for whatever reason).
X-original-commit: 12db61b787b2035bf0c1f2a68a24449d484744c8
Diffstat (limited to 'odoo')
| -rw-r--r-- | odoo/addons/test_new_api/tests/test_new_fields.py | 4 | ||||
| -rw-r--r-- | odoo/models.py | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/odoo/addons/test_new_api/tests/test_new_fields.py b/odoo/addons/test_new_api/tests/test_new_fields.py index ee89c51ab8d..97d1cb2dacc 100644 --- a/odoo/addons/test_new_api/tests/test_new_fields.py +++ b/odoo/addons/test_new_api/tests/test_new_fields.py @@ -2615,6 +2615,7 @@ class TestSelectionOndeleteAdvanced(common.TransactionCase): def test_ondelete_unexisting_policy(self): class Foo(models.Model): + _module = None _inherit = self.MODEL_REQUIRED my_selection = fields.Selection(selection_add=[ @@ -2628,6 +2629,7 @@ class TestSelectionOndeleteAdvanced(common.TransactionCase): def test_ondelete_default_no_default(self): class Foo(models.Model): + _module = None _inherit = self.MODEL_BASE my_selection = fields.Selection(selection_add=[ @@ -2641,6 +2643,7 @@ class TestSelectionOndeleteAdvanced(common.TransactionCase): def test_ondelete_required_null_explicit(self): class Foo(models.Model): + _module = None _inherit = self.MODEL_REQUIRED my_selection = fields.Selection(selection_add=[ @@ -2654,6 +2657,7 @@ class TestSelectionOndeleteAdvanced(common.TransactionCase): def test_ondelete_required_null_implicit(self): class Foo(models.Model): + _module = None _inherit = self.MODEL_REQUIRED my_selection = fields.Selection(selection_add=[ diff --git a/odoo/models.py b/odoo/models.py index 8a46be32f1f..ee8bf814211 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -161,7 +161,7 @@ class MetaModel(api.Meta): self._module = self._get_addon_name(self.__module__) # Remember which models to instanciate for this module. - if not self._custom: + if self._module: self.module_to_models[self._module].append(self) # check for new-api conversion error: leave comma after field definition |
