[IMP] orm: don't compute twice the same function for stored fields if two fields have the same trigger function
bzr revid: mat@openerp.com-20130930140515-4kbzkotjh2ify5vm
This commit is contained in:
parent
46020a08da
commit
7fc046e6b3
|
@ -4533,9 +4533,13 @@ class BaseModel(object):
|
|||
if ((not f[trigger_fields_]) or set(fields).intersection(f[trigger_fields_]))]
|
||||
|
||||
mapping = {}
|
||||
fresults = {}
|
||||
for function in to_compute:
|
||||
# use admin user for accessing objects having rules defined on store fields
|
||||
target_ids = [id for id in function[id_mapping_fnct_](self, cr, SUPERUSER_ID, ids, context) if id]
|
||||
fid = id(function[id_mapping_fnct_])
|
||||
if not fid in fresults:
|
||||
# use admin user for accessing objects having rules defined on store fields
|
||||
fresults[fid] = [id2 for id2 in function[id_mapping_fnct_](self, cr, SUPERUSER_ID, ids, context) if id2]
|
||||
target_ids = fresults[fid]
|
||||
|
||||
# the compound key must consider the priority and model name
|
||||
key = (function[priority_], function[model_name_])
|
||||
|
@ -4556,8 +4560,8 @@ class BaseModel(object):
|
|||
functions_ids_maps = {}
|
||||
# function_ids_maps =
|
||||
# { (function_1_tuple, function_2_tuple) : [target_id1, target_id2, ..] }
|
||||
for id, functions in id_map.iteritems():
|
||||
functions_ids_maps.setdefault(tuple(functions), []).append(id)
|
||||
for fid, functions in id_map.iteritems():
|
||||
functions_ids_maps.setdefault(tuple(functions), []).append(fid)
|
||||
for functions, ids in functions_ids_maps.iteritems():
|
||||
call_map.setdefault((priority,model),[]).append((priority, model, ids,
|
||||
[f[func_field_to_compute_] for f in functions]))
|
||||
|
|
Loading…
Reference in New Issue