[IMP] models: in recompute, do not store fields that should not be recomputed

Consider a new field that uses the same compute method as another existing
field.  When the field is introduced in database, its value must be computed on
existing records.  In such a case, the existing field should not be written, as
its value is not supposed to have changed.  Not writing on the existing field
can avoid useless recomputations in cascade, which is the reason we introduce
this patch.
This commit is contained in:
Raphael Collet 2015-05-06 14:37:56 +02:00
parent 6b72008c32
commit 1a535b9d87
1 changed files with 5 additions and 1 deletions

View File

@ -5667,7 +5667,11 @@ class BaseModel(object):
while self.env.has_todo():
field, recs = self.env.get_todo()
# evaluate the fields to recompute, and save them to database
names = [f.name for f in field.computed_fields if f.store]
names = [
f.name
for f in field.computed_fields
if f.store and self.env.field_todo(f)
]
for rec in recs:
try:
values = rec._convert_to_write({