diff options
| author | Raphael Collet <rco@odoo.com> | 2019-09-04 11:19:11 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2019-09-10 13:29:15 +0000 |
| commit | 1315a1a82c0f09f4f97a04b26bedb590ceb8ecbb (patch) | |
| tree | fc206caa955d739cb5069782845181bd7c9a4562 /odoo/fields.py | |
| parent | 3076ea8b1023d6b81a5db9674182598eb8cd63ac (diff) | |
[FIX] fields: clash with automatic fields and inheritance
Consider a model M that defines `display_name` as a computed stored
field, then an extension of M that introduces a mixin model A before
that definition in the MRO of M's class. The model A is expected to
have an automatic, non stored field `display_name`, while M must have
its non-automatic, stored field `display_name`.
closes odoo/odoo#36427
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/fields.py')
| -rw-r--r-- | odoo/fields.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/odoo/fields.py b/odoo/fields.py index 0210eea5630..9e285517674 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -49,11 +49,12 @@ def first(records): def resolve_mro(model, name, predicate): """ Return the list of successively overridden values of attribute ``name`` - in mro order on ``model`` that satisfy ``predicate``. + in mro order on ``model`` that satisfy ``predicate``. Model classes + (the ones that appear in the registry) are ignored. """ result = [] for cls in type(model).__mro__: - if name in cls.__dict__: + if not getattr(cls, 'pool', None) and name in cls.__dict__: value = cls.__dict__[name] if not predicate(value): break @@ -392,6 +393,9 @@ class Field(MetaField('DummyField', (object,), {})): # determine all inherited field attributes modules = set() attrs = {} + if self.args.get('automatic') and resolve_mro(model, name, self._can_setup_from): + # prevent an automatic field from overriding a real field + self.args.clear() if not (self.args.get('automatic') or self.args.get('manual')): # magic and custom fields do not inherit from parent classes for field in reversed(resolve_mro(model, name, self._can_setup_from)): |
