[FIX] models: invoke old-api onchange methods with context
This helps fixing old-api onchange methods with a record id as a parameter. Browsing this record id may be problematic, since it reads the record in an environment with an empty context. This is really problematic when the record is a new record, because such a record only exists in a given environment.
This commit is contained in:
parent
73899fd2dd
commit
6cf7bc8838
|
@ -5715,9 +5715,13 @@ class BaseModel(object):
|
|||
}
|
||||
params = eval("[%s]" % params, global_vars, field_vars)
|
||||
|
||||
# call onchange method
|
||||
# call onchange method with context when possible
|
||||
args = (self._cr, self._uid, self._origin.ids) + tuple(params)
|
||||
method_res = getattr(self._model, method)(*args)
|
||||
try:
|
||||
method_res = getattr(self._model, method)(*args, context=self._context)
|
||||
except TypeError:
|
||||
method_res = getattr(self._model, method)(*args)
|
||||
|
||||
if not isinstance(method_res, dict):
|
||||
return
|
||||
if 'value' in method_res:
|
||||
|
|
Loading…
Reference in New Issue