From afb91fde8113863820383f4434ef5ecfa6b352c2 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 6 Oct 2014 11:56:03 +0200 Subject: [PATCH] [FIX] models: fields_get() shall not return info about fields not set up yet When processing data files during a module installation/upgrade, not all fields are set up yet, in particular relational custom fields. Make fields_get() ignore those fields, so that views can be created/updated and validated, provided they do not refer to those fields... --- openerp/fields.py | 7 ++++--- openerp/models.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openerp/fields.py b/openerp/fields.py index 6a2f0f75fd1..3e0b2a35f76 100644 --- a/openerp/fields.py +++ b/openerp/fields.py @@ -251,6 +251,7 @@ class Field(object): automatic = False # whether the field is automatically created ("magic" field) inherited = False # whether the field is inherited (_inherits) column = None # the column interfaced by the field + setup_done = False # whether the field has been set up name = None # name of the field type = None # type of the field (string) @@ -346,7 +347,7 @@ class Field(object): def reset(self): """ Prepare `self` for a new setup. """ - self._setup_done = False + self.setup_done = False # self._triggers is a set of pairs (field, path) that represents the # computed fields that depend on `self`. When `self` is modified, it # invalidates the cache of each `field`, and registers the records to @@ -359,8 +360,8 @@ class Field(object): and other properties). This method is idempotent: it has no effect if `self` has already been set up. """ - if not self._setup_done: - self._setup_done = True + if not self.setup_done: + self.setup_done = True self._setup(env) def _setup(self, env): diff --git a/openerp/models.py b/openerp/models.py index 603096c926b..35e06db3df0 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -3042,6 +3042,8 @@ class BaseModel(object): for fname, field in self._fields.iteritems(): if allfields and fname not in allfields: continue + if not field.setup_done: + continue if field.groups and not recs.user_has_groups(field.groups): continue res[fname] = field.get_description(recs.env)