Merge lp:~openerp-dev/openobject-server/trunk-opw-573296-port-kbh into lp:openobject-server

Proposed by Khushboo Bhatt(openerp)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-server/trunk-opw-573296-port-kbh
Merge into: lp:openobject-server
Diff against target: 34 lines (+14/-7)
1 file modified
openerp/osv/orm.py (+14/-7)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-opw-573296-port-kbh
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+138939@code.launchpad.net

Description of the change

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.

To post a comment you must log in.

Unmerged revisions

4667. By <Jacques-Etienne Baudoux>

[FIX]osv: inheried columns does not aggregated correctly while doing group by

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/osv/orm.py'
2--- openerp/osv/orm.py 2012-12-08 21:09:54 +0000
3+++ openerp/osv/orm.py 2012-12-10 11:41:28 +0000
4@@ -2651,16 +2651,23 @@
5 raise except_orm(_('Invalid group_by'),
6 _('Invalid group_by specification: "%s".\nA group_by specification must be a list of valid fields.')%(groupby,))
7
8- aggregated_fields = [
9- f for f in fields
10- if f not in ('id', 'sequence')
11- if fget[f]['type'] in ('integer', 'float')
12- if (f in self._columns and getattr(self._columns[f], '_classic_write'))]
13- for f in aggregated_fields:
14+ aggregated_fields= []
15+ for f in fields:
16+ if f in ('id', 'sequence'):
17+ continue
18+ if fget[f]['type'] not in ('integer', 'float'):
19+ continue
20+ if (f in self._columns and getattr(self._columns[f], '_classic_write')):
21+ table = self._table
22+ elif (f in self._inherit_fields and getattr(self._inherit_fields[f][2], '_classic_write')):
23+ table = self._inherit_fields[f][0].replace('.','_')
24+ else:
25+ continue
26+ aggregated_fields.append(f)
27 group_operator = fget[f].get('group_operator', 'sum')
28 if flist:
29 flist += ', '
30- qualified_field = '"%s"."%s"' % (self._table, f)
31+ qualified_field = '"%s"."%s"' % (table, f)
32 flist += "%s(%s) AS %s" % (group_operator, qualified_field, f)
33
34 gb = groupby and (' GROUP BY ' + qualified_groupby_field) or ''