[FIX] models: make sure an environment is available when we access field.digits
Accessing `field.digits` can crash if no environment is available at that point. This happens in function `get_pg_type()`, which is called from method `_auto_init()`. An environment is simply created in the method's scope to be available for `field.digits`.
This commit is contained in:
parent
071152216f
commit
0c665edb66
|
@ -2431,6 +2431,11 @@ class BaseModel(object):
|
|||
# has not been added in database yet!
|
||||
context = dict(context or {}, prefetch_fields=False)
|
||||
|
||||
# Make sure an environment is available for get_pg_type(). This is
|
||||
# because we access column.digits, which retrieves a cursor from
|
||||
# existing environments.
|
||||
env = api.Environment(cr, SUPERUSER_ID, context)
|
||||
|
||||
store_compute = False
|
||||
stored_fields = [] # new-style stored fields with compute
|
||||
todo_end = []
|
||||
|
|
Loading…
Reference in New Issue