Rifakat (OpenERP) has proposed merging
lp:~openerp-dev/openobject-server/6.1-opw-573296-rha into
lp:openobject-server/6.1.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/6.1-opw-573296-rha/+merge/99909
Hello,
Inherited columns does not aggregated correctly in group by.
Can be reproduced from menu "Timesheet Lines", column Quantity.
Please review this fix.
Regards,
Rifakat
--
https://code.launchpad.net/~openerp-dev/openobject-server/6.1-opw-573296-rha/+merge/99909
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/6.1-opw-573296-rha.
=== modified file 'openerp/osv/orm.py'
--- openerp/osv/orm.py 2012-03-23 11:17:50 +0000
+++ openerp/osv/orm.py 2012-03-29 11:02:54 +0000
@@ -2528,19 +2528,26 @@
# Don't allow arbitrary values, as this would be a SQL injection vector!
raise except_orm(_('Invalid group_by'),
_('Invalid group_by specification: "%s".\nA group_by specification must be a list of valid fields.')%(groupby,))
-
- aggregated_fields = [
- f for f in fields
- if f not in ('id', 'sequence')
- if fget[f]['type'] in ('integer', 'float')
- if (f in self._columns and getattr(self._columns[f], '_classic_write'))]
- for f in aggregated_fields:
+
+ aggregated_fields= []
+ for f in fields:
+ if f in ('id', 'sequence'):
+ continue
+ if fget[f]['type'] not in ('integer', 'float'):
+ continue
+ if (f in self._columns and getattr(self._columns[f], '_classic_write')):
+ table = self._table
+ elif (f in self._inherit_fields and getattr(self._inherit_fields[f][2], '_classic_write')):
+ table = self._inherit_fields[f][0].replace('.','_')
+ else:
+ continue
+ aggregated_fields.append(f)
group_operator = fget[f].get('group_operator', 'sum')
if flist:
flist += ', '
- qualified_field = '"%s"."%s"' % (self._table, f)
+ qualified_field = '"%s"."%s"' % (table, f)
flist += "%s(%s) AS %s" % (group_operator, qualified_field, f)
-
+
gb = groupby and (' GROUP BY ' + qualified_groupby_field) or ''
from_clause, where_clause, where_clause_params = query.get_sql()
@@ -2583,7 +2590,7 @@
del alldata[d['id']][groupby]
d.update(alldata[d['id']])
del d['id']
-
+
if groupby and groupby in self._group_by_full:
data = self._read_group_fill_results(cr, uid, domain, groupby, groupby_list,
aggregated_fields, data, read_group_order=order,
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp