[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`.
This commit is contained in:
parent
7ffbb8d142
commit
a6a1764b2c
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue