From e12ed00e4f47bbce5aade55e2407792ba5cd8b6e Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 15 Jun 2012 15:14:27 +0200 Subject: [PATCH] [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 --- openerp/osv/orm.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 68fb3faefbc..5d2bfd388a8 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -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: