[IMP] list : groupby field can be sorted

bzr revid: tfr@openerp.com-20101119131338-7zfxqphrd5fv0bxq
This commit is contained in:
nch@tinyerp.com 2010-11-19 14:13:38 +01:00 committed by Thibault Francois
parent 68711fc7e8
commit 6b1beeae18
1 changed files with 3 additions and 3 deletions

View File

@ -403,7 +403,7 @@ class orm_template(object):
"""Override this method to do specific things when a view on the object is opened."""
pass
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None):
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, orderby=False, context=None):
raise NotImplementedError(_('The read_group method is not implemented on this object !'))
def _field_create(self, cr, context=None):
@ -2200,7 +2200,7 @@ class orm(orm_template):
_protected = ['read', 'write', 'create', 'default_get', 'perm_read', 'unlink', 'fields_get', 'fields_view_get', 'search', 'name_get', 'distinct_field_get', 'name_search', 'copy', 'import_data', 'search_count', 'exists']
__logger = logging.getLogger('orm')
__schema = logging.getLogger('orm.schema')
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None):
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, orderby=False, context=None):
"""
Get the list of records in list view grouped by the given ``groupby`` fields
@ -2282,7 +2282,7 @@ class orm(orm_template):
alldata[r['id']] = r
del r['id']
if groupby and fget[groupby]['type'] == 'many2one':
data_ids = self.search(cr, uid, [('id', 'in', alldata.keys())], order=groupby, context=context)
data_ids = self.search(cr, uid, [('id', 'in', alldata.keys())], order=orderby or groupby, context=context)
# the IDS of the records that has groupby field value = False or ''
# should be added too
data_ids += filter(lambda x:x not in data_ids, alldata.keys())