← Back to team overview

openerp-india team mailing list archive

[Bug 1017969] [NEW] Some views in CRM fail with an error

 

Public bug reported:

After updating OpenERP 6.1, some views in Sales → Reporting that are
created by the Helpdesk, Claims and Phonecall modules report an error
when loading.

The trace is:

Server Traceback (most recent call last):
  File "/home/andre/production/openerp-web/addons/web/common/http.py", line 593, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/andre/production/openerp/netsvc.py", line 360, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/andre/production/openerp/service/web_services.py", line 586, in dispatch
    res = fn(db, uid, *params)
  File "/home/andre/production/openerp/osv/osv.py", line 167, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/andre/production/openerp/osv/osv.py", line 121, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/andre/production/openerp/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/andre/production/openerp/osv/osv.py", line 164, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/andre/production/openerp/osv/orm.py", line 2572, in read_group
    data_dict = dict((d['id'], d[groupby]) for d in data)
  File "/home/andre/production/openerp/osv/orm.py", line 2572, in <genexpr>
    data_dict = dict((d['id'], d[groupby]) for d in data)
TypeError: unhashable type: 'list'

I pinpointed the change to revision 4201, which changed the read_group
method in orm.py:

=== modified file 'openerp/osv/orm.py'
--- openerp/osv/orm.py	2012-06-08 21:30:18 +0000
+++ openerp/osv/orm.py	2012-06-09 01:05:49 +0000
@@ -2564,13 +2564,15 @@
 
        def append_left(left_side):
            grouped_value = left_side[groupby] and left_side[groupby][0]
            if not grouped_value in known_values:
         order = orderby or groupby
         data_ids = self.search(cr, uid, [('id', 'in', alldata.keys())], order=order, context=context)
+        
         # the IDS of records that have groupby field value = False or '' should be sorted too
-        data_ids += filter(lambda x:x not in data_ids, alldata.keys())
+        data_ids += set(alldata.keys()).difference(data_ids)    
         data = self.read(cr, uid, data_ids, groupby and [groupby] or ['id'], context=context)
-        # restore order of the search as read() uses the default _order (this is only for groups, so the size of data_read shoud be small):
-        data.sort(lambda x,y: cmp(data_ids.index(x['id']), data_ids.index(y['id'])))
+        # restore order of the search as read() uses the default _order (this is only for groups, so the footprint of data should be small):
+        data_dict = dict((d['id'], d[groupby]) for d in data) 
+        result = [{'id': i, groupby: data_dict[i]} for i in data_ids]
 
-        for d in data:
+        for d in result:
             if groupby:
                 d['__domain'] = [(groupby, '=', alldata[d['id']][groupby] or False)] + domain

When the parameter 'groupby' is an empty list, the d[grouby] call fails,
and that's what happens when those views are loaded.

** Affects: openobject-server
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/1017969

Title:
  Some views in CRM fail with an error

Status in OpenERP Server:
  New

Bug description:
  After updating OpenERP 6.1, some views in Sales → Reporting that are
  created by the Helpdesk, Claims and Phonecall modules report an error
  when loading.

  The trace is:

  Server Traceback (most recent call last):
    File "/home/andre/production/openerp-web/addons/web/common/http.py", line 593, in send
      return openerp.netsvc.dispatch_rpc(service_name, method, args)
    File "/home/andre/production/openerp/netsvc.py", line 360, in dispatch_rpc
      result = ExportService.getService(service_name).dispatch(method, params)
    File "/home/andre/production/openerp/service/web_services.py", line 586, in dispatch
      res = fn(db, uid, *params)
    File "/home/andre/production/openerp/osv/osv.py", line 167, in execute_kw
      return self.execute(db, uid, obj, method, *args, **kw or {})
    File "/home/andre/production/openerp/osv/osv.py", line 121, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "/home/andre/production/openerp/osv/osv.py", line 176, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/home/andre/production/openerp/osv/osv.py", line 164, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "/home/andre/production/openerp/osv/orm.py", line 2572, in read_group
      data_dict = dict((d['id'], d[groupby]) for d in data)
    File "/home/andre/production/openerp/osv/orm.py", line 2572, in <genexpr>
      data_dict = dict((d['id'], d[groupby]) for d in data)
  TypeError: unhashable type: 'list'

  I pinpointed the change to revision 4201, which changed the read_group
  method in orm.py:

  === modified file 'openerp/osv/orm.py'
  --- openerp/osv/orm.py	2012-06-08 21:30:18 +0000
  +++ openerp/osv/orm.py	2012-06-09 01:05:49 +0000
  @@ -2564,13 +2564,15 @@
   
          def append_left(left_side):
              grouped_value = left_side[groupby] and left_side[groupby][0]
              if not grouped_value in known_values:
           order = orderby or groupby
           data_ids = self.search(cr, uid, [('id', 'in', alldata.keys())], order=order, context=context)
  +        
           # the IDS of records that have groupby field value = False or '' should be sorted too
  -        data_ids += filter(lambda x:x not in data_ids, alldata.keys())
  +        data_ids += set(alldata.keys()).difference(data_ids)    
           data = self.read(cr, uid, data_ids, groupby and [groupby] or ['id'], context=context)
  -        # restore order of the search as read() uses the default _order (this is only for groups, so the size of data_read shoud be small):
  -        data.sort(lambda x,y: cmp(data_ids.index(x['id']), data_ids.index(y['id'])))
  +        # restore order of the search as read() uses the default _order (this is only for groups, so the footprint of data should be small):
  +        data_dict = dict((d['id'], d[groupby]) for d in data) 
  +        result = [{'id': i, groupby: data_dict[i]} for i in data_ids]
   
  -        for d in data:
  +        for d in result:
               if groupby:
                   d['__domain'] = [(groupby, '=', alldata[d['id']][groupby] or False)] + domain

  When the parameter 'groupby' is an empty list, the d[grouby] call
  fails, and that's what happens when those views are loaded.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/1017969/+subscriptions


Follow ups

References