[FIX] api: in todo list, group records to recompute by environment (#11267)
The effect of this change is to trigger the recomputation of fields on larger recordsets. This takes advantage of batch computations within compute methods.
This commit is contained in:
parent
d3609f7f19
commit
cb581bc14f
|
@ -892,7 +892,8 @@ class Environment(object):
|
||||||
with all records to recompute for ``field``.
|
with all records to recompute for ``field``.
|
||||||
"""
|
"""
|
||||||
if field in self.all.todo:
|
if field in self.all.todo:
|
||||||
return reduce(operator.or_, self.all.todo[field])
|
ids = set(rid for recs in self.all.todo[field] for rid in recs.ids)
|
||||||
|
return self[field.model_name].browse(ids)
|
||||||
|
|
||||||
def check_todo(self, field, record):
|
def check_todo(self, field, record):
|
||||||
""" Check whether ``field`` must be recomputed on ``record``, and if so,
|
""" Check whether ``field`` must be recomputed on ``record``, and if so,
|
||||||
|
@ -905,7 +906,12 @@ class Environment(object):
|
||||||
def add_todo(self, field, records):
|
def add_todo(self, field, records):
|
||||||
""" Mark ``field`` to be recomputed on ``records``. """
|
""" Mark ``field`` to be recomputed on ``records``. """
|
||||||
recs_list = self.all.todo.setdefault(field, [])
|
recs_list = self.all.todo.setdefault(field, [])
|
||||||
recs_list.append(records)
|
for i, recs in enumerate(recs_list):
|
||||||
|
if recs.env == records.env:
|
||||||
|
recs_list[i] |= records
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
recs_list.append(records)
|
||||||
|
|
||||||
def remove_todo(self, field, records):
|
def remove_todo(self, field, records):
|
||||||
""" Mark ``field`` as recomputed on ``records``. """
|
""" Mark ``field`` as recomputed on ``records``. """
|
||||||
|
|
Loading…
Reference in New Issue