From a6a1764b2cdfc18dd6bc9718ccf431f0e0fe9b1f Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 23 Feb 2015 18:33:26 +0100 Subject: [PATCH] [FIX] models: initialize `_fields` attribute. Custom fields can point to custom models that have not been initialized yet (`_setup_base` not called). Ensure every models in the registry have a `_fields` attribute. Use a `frozendict` as a defensive check to ensure it wont be modified before calling `_setup_base`. --- openerp/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/models.py b/openerp/models.py index 7dd628054a1..f8c4e5deb60 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -64,7 +64,7 @@ from .api import Environment from .exceptions import except_orm, AccessError, MissingError, ValidationError from .osv import fields from .osv.query import Query -from .tools import lazy_property, ormcache +from .tools import frozendict, lazy_property, ormcache from .tools.config import config from .tools.misc import CountingStream, DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT from .tools.safe_eval import safe_eval as eval @@ -638,6 +638,7 @@ class BaseModel(object): '_register': False, '_columns': None, # recomputed in _setup_fields() '_defaults': None, # recomputed in _setup_base() + '_fields': frozendict(), # idem '_inherits': dict(cls._inherits), '_depends': dict(cls._depends), '_constraints': list(cls._constraints),