Fix reading from cache in field one2many
issue2706 review419001
This commit is contained in:
1 parent
fb739994c6
commit
5a0fd034cb
2 files changed
+12
-1
No files matched your search
@@ -108,7 +108,12 @@ class One2Many(Field):
|
||||
for i in chain(*ids2):
|
||||
if i in cache[self.model_name] \
|
||||
and self.field in cache[self.model_name][i]:
|
||||
res[cache[self.model_name][i][self.field].id].append(i)
|
||||
if field._type == 'reference':
|
||||
_, id_ = cache[self.model_name][i][self.field].split(',')
|
||||
id_ = int(id_)
|
||||
else:
|
||||
id_ = cache[self.model_name][i][self.field]
|
||||
res[id_].append(i)
|
||||
else:
|
||||
ids3.append(i)
|
||||
|
||||
|
||||
@@ -2504,6 +2504,12 @@ class FieldsTestCase(unittest.TestCase):
|
||||
self.assertEqual(len(one2many1['targets']), 1)
|
||||
target1_id, = one2many1['targets']
|
||||
|
||||
# Try with target1 stored in cache
|
||||
target1 = one2many_target.browse(target1_id)
|
||||
target1.origin
|
||||
one2many1 = one2many.read(one2many1_id, ['targets'])
|
||||
self.assertEqual(one2many1['targets'], [target1_id])
|
||||
|
||||
one2many_ids = one2many.search([
|
||||
('targets', '=', 'target1'),
|
||||
])
|
||||
|
||||
Reference in new issue
Block a user