[IMP] fields: avoid search when recomputing a field on the same records

This avoids a few dumb queries.
This commit is contained in:
Raphael Collet
2015-09-18 18:12:23 +02:00
parent 7d558a9a86
commit 3a1483635e
+6 -3
View File
@@ -956,9 +956,12 @@ class Field(object):
spec = [(self, records._ids)]
for field, path in records._field_triggers[self]:
if path and field.store:
# don't move this line to function top, see log
env = records.env(user=SUPERUSER_ID, context={'active_test': False})
target = env[field.model_name].search([(path, 'in', records.ids)])
if path == 'id':
target = records
else:
# don't move this line to function top, see log
env = records.env(user=SUPERUSER_ID, context={'active_test': False})
target = env[field.model_name].search([(path, 'in', records.ids)])
if target:
spec.append((field, target._ids))
# recompute field on target in the environment of records,