openerp 7.0 read_group dont compute aggreated fields on inherits table

Bug #1210177 reported by Serge
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D
OpenERP Community Backports (Server)
Status tracked in 7.0
7.0
New
Undecided
Unassigned

Bug Description

If you look in human Resources-> timesheet activities, by default we have a total on Duration columns, this fields come from account analytic line. Sum work fine, but if you try to group by user, you dont have total.

Problem come from osv/orm.py/BaseModel.read_group

2 change needed to fix that

1)
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') or
                f in self._all_columns and getattr(self._all_columns[f].column, '_classic_write') #LOOK IF THE FIELDS COME FROM INHERITS
                )]

This change will tell to openerp to take the fields in aggregated_fields table if he come from a inherits

2)
for f in aggregated_fields:
            group_operator = fget[f].get('group_operator', 'sum')
            if flist:
                flist += ', '
                if f in self._columns: #IF COLUMNS COME FROM TABLE, DO NORMALY
                    qualified_field = '"%s"."%s"' % (self._table, f)
                else:
                    #IF COLUMN COME FROM A INHERITS WE NEED TO ADD __RELATION_FIELD in the table source name
                    qualified_field = '"%s__%s"."%s"' % (self._table,self._all_columns[f].parent_column, f)
            flist += "%s(%s) AS %s" % (group_operator, qualified_field, f)

This Change will tell to openerp which columns he need to include in the Select query.

With this change on our side, all work fine now !

Related branches

Revision history for this message
Craig Gowing (credativ) (craiggowing) wrote :

Hi Serge,

This bug affects me also and I have come up with a similar fix. (Please see attached branch for trunk).

Thanks,
Craig

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello,

Sorry for the response delay, this issue has been fixed in server 7.0 at revision [1]. Have a look at the patch to see how we actually did it (it is a bit different from your proposed patch, there were other side effects to consider).

Thanks for reporting and working on a fix!

[1] 5220 revid:<email address hidden>

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
milestone: none → 7.0
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.