← Back to team overview

openerp-india team mailing list archive

[Bug 1275200] [NEW] products tree view search by location_id generates 'IndexError: pop from empty list' error

 

Public bug reported:

I have experienced this problem with OpenERP 7 (Version
7.0-20140118-002423) and (Version 7.0-20130925-231029)

When searching by stock location in the products tree view, selecting
any of the stock locations (ex: Physical Locations / location 1)
generates the following error:

Server Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 3606, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 3714, in _read_flat
    res2 = self._columns[val[0]].get(cr, self, ids, val, user, context=context, values=res)
  File "/usr/lib/pymodules/python2.7/openerp/osv/fields.py", line 1133, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/usr/lib/pymodules/python2.7/openerp/addons/stock/product.py", line 358, in _product_available
    stock = self.get_product_available(cr, uid, ids, context=c)
  File "/usr/lib/pymodules/python2.7/openerp/addons/stock/product.py", line 245, in get_product_available
    child_location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', location_ids)])
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 2356, in search
    return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 4847, in _search
    query = self._where_calc(cr, user, args, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 4678, in _where_calc
    where_clause, where_params = e.to_sql()
  File "/usr/lib/pymodules/python2.7/openerp/osv/expression.py", line 1214, in to_sql
    q2 = stack.pop()
IndexError: pop from empty list

After checking line 245 of openerp/addons/stock/product.py, it generates
a null value. I think this is because the value returned to
context['location'] is a string containing the actual '/' concatenated
name of the location.

I added the following lines in the code:

After line 231 of openerp/addons/stock/product.py I added:

231            elif type(context['location']) in (type(''), type(u'')):

232                xLoc = context['location']
233                xLocList = xLoc.split('/')
234                if len(xLocList) > 0:
235                    xLocation = xLocList[-1]
236                    context['location'] = xLocation.strip()

It gets the last string in the '/' concatenated location name then
updates the value of context['location'] before this next line gets
executed:

location_ids = location_obj.search(cr, uid,
[('name','ilike',context['location'])], context=context)

This search in the original code is generating a null value when the
stock location is a '/' concatenated name value.

I hope this will help others who are experiencing this same problem.

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


** Tags: by location product.py search stock

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

Title:
  products tree view search by location_id generates 'IndexError: pop
  from empty list' error

Status in OpenERP Addons (modules):
  New

Bug description:
  I have experienced this problem with OpenERP 7 (Version
  7.0-20140118-002423) and (Version 7.0-20130925-231029)

  When searching by stock location in the products tree view, selecting
  any of the stock locations (ex: Physical Locations / location 1)
  generates the following error:

  Server Traceback (most recent call last):
    File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 89, in send
      return openerp.netsvc.dispatch_rpc(service_name, method, args)
    File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 292, in dispatch_rpc
      result = ExportService.getService(service_name).dispatch(method, params)
    File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 626, in dispatch
      res = fn(db, uid, *params)
    File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 188, in execute_kw
      return self.execute(db, uid, obj, method, *args, **kw or {})
    File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 131, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 197, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 185, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 3606, in read
      result = self._read_flat(cr, user, select, fields, context, load)
    File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 3714, in _read_flat
      res2 = self._columns[val[0]].get(cr, self, ids, val, user, context=context, values=res)
    File "/usr/lib/pymodules/python2.7/openerp/osv/fields.py", line 1133, in get
      result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
    File "/usr/lib/pymodules/python2.7/openerp/addons/stock/product.py", line 358, in _product_available
      stock = self.get_product_available(cr, uid, ids, context=c)
    File "/usr/lib/pymodules/python2.7/openerp/addons/stock/product.py", line 245, in get_product_available
      child_location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', location_ids)])
    File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 2356, in search
      return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
    File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 4847, in _search
      query = self._where_calc(cr, user, args, context=context)
    File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 4678, in _where_calc
      where_clause, where_params = e.to_sql()
    File "/usr/lib/pymodules/python2.7/openerp/osv/expression.py", line 1214, in to_sql
      q2 = stack.pop()
  IndexError: pop from empty list

  After checking line 245 of openerp/addons/stock/product.py, it
  generates a null value. I think this is because the value returned to
  context['location'] is a string containing the actual '/' concatenated
  name of the location.

  I added the following lines in the code:

  After line 231 of openerp/addons/stock/product.py I added:

  231            elif type(context['location']) in (type(''),
  type(u'')):

  232                xLoc = context['location']
  233                xLocList = xLoc.split('/')
  234                if len(xLocList) > 0:
  235                    xLocation = xLocList[-1]
  236                    context['location'] = xLocation.strip()

  It gets the last string in the '/' concatenated location name then
  updates the value of context['location'] before this next line gets
  executed:

  location_ids = location_obj.search(cr, uid,
  [('name','ilike',context['location'])], context=context)

  This search in the original code is generating a null value when the
  stock location is a '/' concatenated name value.

  I hope this will help others who are experiencing this same problem.

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


Follow ups

References