[FIX] read_group: empty groupby case broken by last read_group patch

Revision 4201 broke the case where groupby == []
by mistake.
r.4201 = rev-id odo@openerp.com-20120609010549-xdktw6xte7fmxjbq

bzr revid: odo@openerp.com-20120615131427-daf5kd5s17my8gnb
This commit is contained in:
Olivier Dony
2012-06-15 15:14:27 +02:00
parent 526f75141a
commit e12ed00e4f
+10 -6
View File
@@ -2565,12 +2565,16 @@ class BaseModel(object):
order = orderby or groupby
data_ids = self.search(cr, uid, [('id', 'in', alldata.keys())], order=order, context=context)
# the IDS of records that have groupby field value = False or '' should be sorted too
data_ids += set(alldata.keys()).difference(data_ids)
data = self.read(cr, uid, data_ids, groupby and [groupby] or ['id'], context=context)
# restore order of the search as read() uses the default _order (this is only for groups, so the footprint of data should be small):
data_dict = dict((d['id'], d[groupby]) for d in data)
result = [{'id': i, groupby: data_dict[i]} for i in data_ids]
# the IDs of records that have groupby field value = False or '' should be included too
data_ids += set(alldata.keys()).difference(data_ids)
if groupby:
data = self.read(cr, uid, data_ids, [groupby], context=context)
# restore order of the search as read() uses the default _order (this is only for groups, so the footprint of data should be small):
data_dict = dict((d['id'], d[groupby] ) for d in data)
result = [{'id': i, groupby: data_dict[i]} for i in data_ids]
else:
result = [{'id': i} for i in data_ids]
for d in result:
if groupby: