~openerp-dev/openobject-server/7.0-orm-fix_groupby-acl

« back to all changes in this revision

Viewing changes to openerp/osv/orm.py

  • Committer: Martin Trigaux
  • Date: 2014-02-03 14:02:47 UTC
  • mfrom: (5219.1.3 aggregated-groupby)
  • Revision ID: mat@openerp.com-20140203140247-n090tx2yf8mujkcz
[MERGE] [FIX] read_group: aggregate values on all columns instead of only the one of the current model

Without this you could not have a sum value on a column belonging to the parent model (eg: 'unit_amount' when grouping on hr.analytic.timesheet)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2670
2670
            f for f in fields
2671
2671
            if f not in ('id', 'sequence')
2672
2672
            if fget[f]['type'] in ('integer', 'float')
2673
 
            if (f in self._columns and getattr(self._columns[f], '_classic_write'))]
 
2673
            if (f in self._all_columns and getattr(self._all_columns[f].column, '_classic_write'))]
2674
2674
        for f in aggregated_fields:
2675
2675
            group_operator = fget[f].get('group_operator', 'sum')
2676
2676
            if flist:
2677
2677
                flist += ', '
2678
 
            qualified_field = '"%s"."%s"' % (self._table, f)
 
2678
            qualified_field = self._inherits_join_calc(f, query)
2679
2679
            flist += "%s(%s) AS %s" % (group_operator, qualified_field, f)
2680
2680
 
2681
2681
        gb = groupby and (' GROUP BY ' + qualified_groupby_field) or ''