Khushboo Bhatt(openerp) has proposed merging 
lp:~openerp-dev/openobject-server/trunk-opw-573296-port-kbh into 
lp:openobject-server.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-opw-573296-port-kbh/+merge/138939

Hello,

Inherited columns does not aggregated correctly in group by.

Can be reproduced from menu "Timesheet Lines", column Quantity.

Please review this fix.

Code is forward port from 6.1

Thanks,
Khushboo.
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-opw-573296-port-kbh/+merge/138939
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-server/trunk-opw-573296-port-kbh.
=== modified file 'openerp/osv/orm.py'
--- openerp/osv/orm.py	2012-12-08 21:09:54 +0000
+++ openerp/osv/orm.py	2012-12-10 11:41:28 +0000
@@ -2651,16 +2651,23 @@
                 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 ''

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to