← Back to team overview

credativ team mailing list archive

[Bug 909782] [NEW] Sales order tree view error: KeyError: 'number_of_stockable'

 

Public bug reported:

Hi, 
After installing project_mrp, if you create a sales_order without any lines you cant come back to it. The tree view gives the following error :

Client Traceback (most recent call last):
  File "/home/openerp/bazaar/trunk/openerp-web/addons/web/common/http.py", line 175, in dispatch
    response["result"] = method(controller, self, **self.params)
  File "/home/openerp/bazaar/trunk/openerp-web/addons/web/controllers/main.py", line 722, in search_read
    return self.do_search_read(req, model, fields, offset, limit, domain, sort)
  File "/home/openerp/bazaar/trunk/openerp-web/addons/web/controllers/main.py", line 758, in do_search_read
    records = Model.read(paginated_ids, fields or False, context)
  File "/home/openerp/bazaar/trunk/openerp-web/addons/web/common/openerplib/main.py", line 430, in proxy
    *args)
  File "/home/openerp/bazaar/trunk/openerp-web/addons/web/common/openerplib/main.py", line 306, in proxy
    result = self.connector.send(self.service_name, method, *args)
  File "/home/openerp/bazaar/trunk/openerp-web/addons/web/common/openerplib/main.py", line 276, in send
    raise fault


Server Traceback (most recent call last):
  File "/home/openerp/bazaar/trunk/openerp-web/addons/web/common/openerplib/main.py", line 257, in send
    result = openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/netsvc.py", line 325, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/service/web_services.py", line 580, in dispatch
    res = fn(db, uid, *params)
  File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/osv.py", line 120, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/osv.py", line 172, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/osv.py", line 163, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/orm.py", line 3367, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/orm.py", line 3492, in _read_flat
    res2 = self._columns[f].get(cr, self, ids, f, user, context=context, values=res)
  File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/fields.py", line 1048, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/home/openerp/bazaar/trunk/openobject-addons/project_mrp/project_mrp.py", line 101, in _picked_rate
    res_sale[sale.id]['number_of_stockable'] -= res_sale[sale.id]['total_no_task']
KeyError: 'number_of_stockable'


The error is in the following code:


        #compute the sum of quantity for each SO
        cr.execute('''select sol.order_id as sale_id, sum(sol.product_uom_qty) as total
                    from sale_order_line sol where sol.order_id in %s group by sol.order_id''',(tuple(ids),))
        total_qtty_ref = cr.dictfetchall()
        for item in total_qtty_ref:
            res_sale[item['sale_id']]['number_of_stockable'] = item['total']

If the order has no line, the key is never initialized and produces a
key error later on.

Thanks,
Gautam

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

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

Title:
  Sales order tree view error: KeyError: 'number_of_stockable'

Status in OpenERP Addons (modules):
  New

Bug description:
  Hi, 
  After installing project_mrp, if you create a sales_order without any lines you cant come back to it. The tree view gives the following error :

  Client Traceback (most recent call last):
    File "/home/openerp/bazaar/trunk/openerp-web/addons/web/common/http.py", line 175, in dispatch
      response["result"] = method(controller, self, **self.params)
    File "/home/openerp/bazaar/trunk/openerp-web/addons/web/controllers/main.py", line 722, in search_read
      return self.do_search_read(req, model, fields, offset, limit, domain, sort)
    File "/home/openerp/bazaar/trunk/openerp-web/addons/web/controllers/main.py", line 758, in do_search_read
      records = Model.read(paginated_ids, fields or False, context)
    File "/home/openerp/bazaar/trunk/openerp-web/addons/web/common/openerplib/main.py", line 430, in proxy
      *args)
    File "/home/openerp/bazaar/trunk/openerp-web/addons/web/common/openerplib/main.py", line 306, in proxy
      result = self.connector.send(self.service_name, method, *args)
    File "/home/openerp/bazaar/trunk/openerp-web/addons/web/common/openerplib/main.py", line 276, in send
      raise fault

  
  Server Traceback (most recent call last):
    File "/home/openerp/bazaar/trunk/openerp-web/addons/web/common/openerplib/main.py", line 257, in send
      result = openerp.netsvc.dispatch_rpc(service_name, method, args)
    File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/netsvc.py", line 325, in dispatch_rpc
      result = ExportService.getService(service_name).dispatch(method, params)
    File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/service/web_services.py", line 580, in dispatch
      res = fn(db, uid, *params)
    File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/osv.py", line 120, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/osv.py", line 172, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/osv.py", line 163, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/orm.py", line 3367, in read
      result = self._read_flat(cr, user, select, fields, context, load)
    File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/orm.py", line 3492, in _read_flat
      res2 = self._columns[f].get(cr, self, ids, f, user, context=context, values=res)
    File "/home/openerp/bazaar/trunk/openERP/development/lptrunk/openobject-server/openerp/osv/fields.py", line 1048, in get
      result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
    File "/home/openerp/bazaar/trunk/openobject-addons/project_mrp/project_mrp.py", line 101, in _picked_rate
      res_sale[sale.id]['number_of_stockable'] -= res_sale[sale.id]['total_no_task']
  KeyError: 'number_of_stockable'

  
  The error is in the following code:

  
          #compute the sum of quantity for each SO
          cr.execute('''select sol.order_id as sale_id, sum(sol.product_uom_qty) as total
                      from sale_order_line sol where sol.order_id in %s group by sol.order_id''',(tuple(ids),))
          total_qtty_ref = cr.dictfetchall()
          for item in total_qtty_ref:
              res_sale[item['sale_id']]['number_of_stockable'] = item['total']

  If the order has no line, the key is never initialized and produces a
  key error later on.

  Thanks,
  Gautam

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


Follow ups

References