diff options
| author | Julien Castiaux <juc@odoo.com> | 2020-05-27 09:21:38 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-06-22 16:05:56 +0000 |
| commit | 5d5a3d7fa455a93d89688cfb613afeb97f0073d5 (patch) | |
| tree | 9cb08de23263ca58a3d649491a42dbf90d317dfe /odoo/models.py | |
| parent | 8d75b794c49e6c05bbb70c5ba19636f576950894 (diff) | |
[FIX] base: missing xmlid for mixin fields
We want to create a XMLID for every first exhibition of a field in a
model. That is, we just want one XMLID by field by model and not one
XMLID by field by class. Previous implementation was determining the
"first field exhibition" by making sure the field was created and used
as part of the same module.
This assumption is invalid when we consider mixins. A mixin is an
abstract model that define fields and methods to be included in other
models. As it is abstract, it does not exhibits the field by itself. The
field will only be exhibited when included in a concrete model via
inheritance. When it is included in another module, the XMLID creation
is discarded.
Take a module M1 that defines a model A, take another module M2 that
defines a mixin X with a field X1. In a third module M3, extend A to
inherit from X. While M3.A is the first model module to exhibit the
field X1, the XMLID creation was discarded because `"M2" != "M3"`.
See https://github.com/odoo/odoo/issues/49354#issuecomment-614093767
Task: 2235368
Closes #49354
closes odoo/odoo#53435
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/models.py')
| -rw-r--r-- | odoo/models.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/odoo/models.py b/odoo/models.py index 0a84b260c4e..42b1344e2e4 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -514,6 +514,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): '_name': name, '_register': False, '_original_module': cls._module, + '_inherit_module': dict(), # map parent to introducing module '_inherit_children': OrderedSet(), # names of children models '_inherits_children': set(), # names of children models '_fields': OrderedDict(), # populated in _setup_base() @@ -532,7 +533,9 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): else: check_parent(cls, parent_class) bases.add(parent_class) + ModelClass._inherit_module[parent] = cls._module parent_class._inherit_children.add(name) + ModelClass.__bases__ = tuple(bases) # determine the attributes of the model's class |
