[6.0RC2] orm groupby doesn't add tablenames to fields and groupby clause

Bug #703105 reported by debaetsr
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D

Bug Description

orm.py, class orm function readgroup line 2167

There are no tablenames added to the fieldname, leading to the following error when grouping projects by parent

1. Create some analytic accounts with parent/childs
2. Create some projects with parent/childs
3. Try a grouped view by parent.

Environment Information :
System : Linux-2.6.35-22-generic-i686-with-Ubuntu-10.04-lucid
OS Name : posix
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid
Operating System Release : 2.6.35-22-generic
Operating System Version : #34~lucid1-Ubuntu SMP Mon Oct 11 14:36:18 UTC 2010
Operating System Architecture : 32bit
Operating System Locale : nl_BE.UTF8
Python Version : 2.6.5
OpenERP-Client Version : 6.0.0-rc2
Last revision No. & ID :0 null:
Traceback (most recent call last):
  File "/home/ruben/workspace/openerp/trunk/server/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/home/ruben/workspace/openerp/trunk/server/bin/service/web_services.py", line 599, in dispatch
    res = fn(db, uid, *params)
  File "/home/ruben/workspace/openerp/trunk/server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/ruben/workspace/openerp/trunk/server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/ruben/workspace/openerp/trunk/server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/ruben/workspace/openerp/trunk/server/bin/osv/orm.py", line 2182, in read_group
    cr.execute('SELECT min(%s.id) AS id, count(%s.id) AS %s_count' % (self._table, self._table, group_count) + (flist and ',') + flist + ' FROM ' + from_clause + where_clause + gb + limit_str + offset_str, where_clause_params)
  File "/home/ruben/workspace/openerp/trunk/server/bin/sql_db.py", line 76, in wrapper
    return f(self, *args, **kwargs)
  File "/home/ruben/workspace/openerp/trunk/server/bin/sql_db.py", line 129, in execute
    res = self._obj.execute(query, params)
ProgrammingError: column reference "parent_id" is ambiguous
LINE 1: ... id, count(project_project.id) AS parent_id_count,parent_id,...
                                                             ^

Solution my be to force the tablename to be joined to the fieldname.

Regards,
Ruben

Related branches

Revision history for this message
xrg (xrg) wrote : Re: [Bug 703105] [NEW] [6.0RC2] orm groupby doesn't add tablenames to fields and groupby clause

On Saturday 15 January 2011, you wrote:
> Public bug reported:
>
> orm.py, class orm function readgroup line 2167
>
> There are no tablenames added to the fieldname, leading to the following
> error when grouping projects by parent
> ProgrammingError: column reference "parent_id" is ambiguous
> LINE 1: ... id, count(project_project.id) AS parent_id_count,parent_id,...
> ^

You are right that the 'group_by' feature should indicate table names.

However, note that project.parent_id has been removed a few commits ago, so
that model won't have a column conflict with its 'account.analytic.account'
base model.

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

Hello,

As xrg said, the problem with projects should be gone in the latest addons, but your suggestion is right, so an improved version of read_group() has been pushed with server revision 3269 <email address hidden>.

Thanks for reporting!

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
milestone: none → 6.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.