[FIX] OPW 575395: orm: don't defer function field computation during creation of parent records (inheritS)
An optimization in the set() method of o2m fields disables the direct computation of function fields in order to avoid computing them line-by-line. This is done with context key 'no_store_function', and deferred at the end of the caller write() or create() method. This was unfortunately disabling all function fields in parent model (via _inheritS) at the time of creation, even though those were *not* batch-computed at the end. The patch removes the 'no_store_function' field in the context that is passed to inheritS parents during creation, as it was never meant to be passed. lp bug: https://launchpad.net/bugs/704922 fixed bzr revid: odo@openerp.com-20120604114536-4t6ulwl93zalfgr7
This commit is contained in:
parent
a6e66b8fa9
commit
14a6cd841f
|
@ -4120,11 +4120,16 @@ class BaseModel(object):
|
|||
del vals[self._inherits[table]]
|
||||
|
||||
record_id = tocreate[table].pop('id', None)
|
||||
|
||||
|
||||
# When linking/creating parent records, force context without 'no_store_function' key that
|
||||
# defers stored functions computing, as these won't be computed in batch at the end of create().
|
||||
parent_context = dict(context)
|
||||
parent_context.pop('no_store_function', None)
|
||||
|
||||
if record_id is None or not record_id:
|
||||
record_id = self.pool.get(table).create(cr, user, tocreate[table], context=context)
|
||||
record_id = self.pool.get(table).create(cr, user, tocreate[table], context=parent_context)
|
||||
else:
|
||||
self.pool.get(table).write(cr, user, [record_id], tocreate[table], context=context)
|
||||
self.pool.get(table).write(cr, user, [record_id], tocreate[table], context=parent_context)
|
||||
|
||||
upd0 += ',' + self._inherits[table]
|
||||
upd1 += ',%s'
|
||||
|
|
Loading…
Reference in New Issue