[FIX] orm.search_read: drop active_test context flag during the read() step

The active_test flag is meant for search(),
but when passed to search_read() it was also
propagated to the read() call.
This has little consequence normally because
read() ignores this flag, but it can have
side-effects when reading x2m fields or
function fields. They are likely to call
search() somewhere downstream, still with
 the propagated active_test flag, while
it should not be applied anymore.

Ultimately dropping this flag could be
done by read() in all cases, but changing
search_read() is less likely to block
exotic cases where the flag was passed
on purpose. Moving it to read() could
be done as a later step.
This commit is contained in:
Olivier Dony 2014-05-13 17:29:35 +02:00
parent fc7a31f842
commit 7e66bd9d55
1 changed files with 8 additions and 1 deletions

View File

@ -5083,7 +5083,14 @@ class BaseModel(object):
# shortcut read if we only want the ids
return [{'id': id} for id in record_ids]
result = self.read(cr, uid, record_ids, fields, context=context)
# read() ignores active_test, but it would forward it to any downstream search call
# (e.g. for x2m or function fields), and this is not the desired behavior, the flag
# was presumably only meant for the main search().
# TODO: Move this to read() directly?
read_ctx = dict(context or {})
read_ctx.pop('active_test', None)
result = self.read(cr, uid, record_ids, fields, context=read_ctx)
if len(result) <= 1:
return result