From: Olivier Dony Date: Thu, 16 Dec 2010 18:37:08 +0000 (+0100) Subject: [IMP] orm.read_group: raise if called with group_by being a non-database-stored field X-Git-Tag: 6.0.0-rc2-addons~75^2~14 X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=0da4773e14e417c3987718152813ee3cee0ff1ec;p=odoo%2Fodoo.git [IMP] orm.read_group: raise if called with group_by being a non-database-stored field lp bug: https://launchpad.net/bugs/689070 fixed bzr revid: odo@openerp.com-20101216183708-o61idware1v6tyk3 --- diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 895626d..a652ad5 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -2276,7 +2276,10 @@ class orm(orm_template): groupby = groupby[0] self._inherits_join_calc(groupby, query) - assert not groupby or groupby in fields, "Fields in 'groupby' must appear in the list of fields to read (perhaps it's missing in the list view?)" + if groupby: + assert not groupby or groupby in fields, "Fields in 'groupby' must appear in the list of fields to read (perhaps it's missing in the list view?)" + groupby_def = self._columns.get(groupby) or (self._inherit_fields.get(groupby) and self._inherit_fields.get(groupby)[2]) + assert groupby_def and groupby_def._classic_write, "Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True" fget = self.fields_get(cr, uid, fields) float_int_fields = filter(lambda x: fget[x]['type'] in ('float', 'integer'), fields)