[FIX] models: improve rationale for the management of flag 'recompute' in context
When the context contains 'recompute': False, the recomputation was not even prepared. Now both create() and write() prepare the recomputation by invoking method modified(). The flag only controls whether method recompute() is invoked. In addintion, the former flag 'no_store_function' was converted to the flag 'recompute', so that both create() and write() use the same flag. Fixes #1456
This commit is contained in:
parent
62b0d99cfe
commit
052f9ed5d7
|
@ -1297,7 +1297,7 @@ class account_move_line(osv.osv):
|
|||
self.create(cr, uid, data, context)
|
||||
del vals['account_tax_id']
|
||||
|
||||
if check and not context.get('novalidate') and ((not context.get('no_store_function')) or journal.entry_posted):
|
||||
if check and not context.get('novalidate') and (context.get('recompute', True) or journal.entry_posted):
|
||||
tmp = move_obj.validate(cr, uid, [vals['move_id']], context)
|
||||
if journal.entry_posted and tmp:
|
||||
move_obj.button_validate(cr,uid, [vals['move_id']], context)
|
||||
|
|
|
@ -137,7 +137,7 @@ class project_work(osv.osv):
|
|||
amount = vals_line['unit_amount']
|
||||
prod_id = vals_line['product_id']
|
||||
unit = False
|
||||
context = dict(context, no_store_function=False)
|
||||
context = dict(context, recompute=True)
|
||||
timeline_id = timesheet_obj.create(cr, uid, vals_line, context=context)
|
||||
|
||||
# Compute based on pricetype
|
||||
|
|
|
@ -3972,15 +3972,10 @@ class BaseModel(object):
|
|||
|
||||
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[table].create(cr, user, tocreate[table], context=parent_context)
|
||||
record_id = self.pool[table].create(cr, user, tocreate[table], context=context)
|
||||
else:
|
||||
self.pool[table].write(cr, user, [record_id], tocreate[table], context=parent_context)
|
||||
self.pool[table].write(cr, user, [record_id], tocreate[table], context=context)
|
||||
|
||||
updates.append((self._inherits[table], '%s', record_id))
|
||||
|
||||
|
@ -4105,13 +4100,13 @@ class BaseModel(object):
|
|||
# check Python constraints
|
||||
recs._validate_fields(vals)
|
||||
|
||||
# Mark new-style fields to recompute
|
||||
# invalidate and mark new-style fields to recompute
|
||||
modified_fields = list(vals)
|
||||
if self._log_access:
|
||||
modified_fields += ['create_uid', 'create_date', 'write_uid', 'write_date']
|
||||
recs.modified(modified_fields)
|
||||
|
||||
if not context.get('no_store_function', False):
|
||||
if context.get('recompute', True):
|
||||
result += self._store_get_values(cr, user, [id_new],
|
||||
list(set(vals.keys() + self._inherits.values())),
|
||||
context)
|
||||
|
@ -4124,7 +4119,7 @@ class BaseModel(object):
|
|||
# recompute new-style fields
|
||||
recs.recompute()
|
||||
|
||||
if self._log_create and not (context and context.get('no_store_function', False)):
|
||||
if self._log_create and context.get('recompute', True):
|
||||
message = self._description + \
|
||||
" '" + \
|
||||
self.name_get(cr, user, [id_new], context=context)[0][1] + \
|
||||
|
@ -4269,7 +4264,7 @@ class BaseModel(object):
|
|||
cr.execute('update "' + self._table + '" set ' + \
|
||||
'"'+f+'"='+self._columns[f]._symbol_set[0] + ' where id = %s', (self._columns[f]._symbol_set[1](value), id))
|
||||
|
||||
# invalidate the cache for the modified fields
|
||||
# invalidate and mark new-style fields to recompute
|
||||
self.browse(cr, uid, ids, context).modified(fields)
|
||||
|
||||
return True
|
||||
|
|
|
@ -684,7 +684,7 @@ class one2many(_column):
|
|||
result = []
|
||||
context = dict(context or {})
|
||||
context.update(self._context)
|
||||
context['no_store_function'] = True
|
||||
context['recompute'] = False # recomputation is done by outer create/write
|
||||
if not values:
|
||||
return
|
||||
obj = obj.pool[self._obj]
|
||||
|
|
Loading…
Reference in New Issue