← Back to team overview

openerp-community-reviewer team mailing list archive

[Bug 1220110] Re: Server crashes executing Duplicate BoM

 

Suggestion on how to manage data type was sufficient to close this
issue.

** Changed in: openobject-server
       Status: New => Invalid

-- 
You received this bug notification because you are a member of OpenERP
Community Backports Team, which is subscribed to OpenERP Community
Backports (Server).
https://bugs.launchpad.net/bugs/1220110

Title:
  Server crashes executing Duplicate BoM

Status in OpenERP Community Backports (Server):
  New
Status in OpenERP Community Backports (Server) 7.0 series:
  New
Status in OpenERP Server:
  Invalid

Bug description:
  1) Query on BoM items, select one and execute "Duplicate"
  2) System crashes reporting the following error:
  Client Traceback (most recent call last):
    File "/opt/server/openerp/addons/web/http.py", line 204, in dispatch
      response["result"] = method(self, **self.params)
    File "/opt/server/openerp/addons/web/controllers/main.py", line 1128, in call_kw
      return self._call_kw(req, model, method, args, kwargs)
    File "/opt/server/openerp/addons/web/controllers/main.py", line 1120, in _call_kw
      return getattr(req.session.model(model), method)(*args, **kwargs)
    File "/opt/server/openerp/addons/web/session.py", line 42, in proxy
      result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)
    File "/opt/server/openerp/addons/web/session.py", line 30, in proxy_method
      result = self.session.send(self.service_name, method, *args)
    File "/opt/server/openerp/addons/web/session.py", line 103, in send
      raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)

  
  Server Traceback (most recent call last):
    File "/opt/server/openerp/addons/web/session.py", line 89, in send
      return openerp.netsvc.dispatch_rpc(service_name, method, args)
    File "/opt/openerp-7.0-20130901-231054/openerp/netsvc.py", line 292, in dispatch_rpc
      result = ExportService.getService(service_name).dispatch(method, params)
    File "/opt/openerp-7.0-20130901-231054/openerp/service/web_services.py", line 626, in dispatch
      res = fn(db, uid, *params)
    File "/opt/openerp-7.0-20130901-231054/openerp/osv/osv.py", line 188, in execute_kw
      return self.execute(db, uid, obj, method, *args, **kw or {})
    File "/opt/openerp-7.0-20130901-231054/openerp/osv/osv.py", line 131, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "/opt/openerp-7.0-20130901-231054/openerp/osv/osv.py", line 197, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/opt/openerp-7.0-20130901-231054/openerp/osv/osv.py", line 185, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "/opt/addons/OpenERPPLM/install/plm_base_entities.py", line 465, in copy
      newId=super(plm_relation,self).copy(cr,uid,oid,defaults,context=context)
    File "/opt/server/openerp/addons/mail/mail_thread.py", line 302, in copy
      return super(mail_thread, self).copy(cr, uid, id, default=default, context=context)
    File "/opt/openerp-7.0-20130901-231054/openerp/osv/orm.py", line 5027, in copy
      data = self.copy_data(cr, uid, id, default, context)
    File "/opt/server/openerp/addons/mrp/mrp.py", line 376, in copy_data
      bom_data = self.read(cr, uid, id, [], context=context)
    File "/opt/openerp-7.0-20130901-231054/openerp/osv/orm.py", line 3606, in read
      result = self._read_flat(cr, user, select, fields, context, load)
    File "/opt/openerp-7.0-20130901-231054/openerp/osv/orm.py", line 3726, in _read_flat
      res2 = self._columns[f].get(cr, self, ids, f, user, context=context, values=res)
    File "/opt/openerp-7.0-20130901-231054/openerp/osv/fields.py", line 1140, in get
      result[id] = self.postprocess(cr, uid, obj, name, result[id], context)
    File "/opt/openerp-7.0-20130901-231054/openerp/osv/fields.py", line 1129, in postprocess
      result = __builtin__.float(value)
  TypeError: float() argument must be a string or a number

  3) I'm expecting to have BoM duplicated.

  4) I'm working on Windows XP, with Google Chrome as browser.
    
  5) I'm working on openerp-7.0-20130901-231054 server version on Debian 7.0 server.
  This crash happens only on unix servers and not on windows ones.
  In my configuration I added some fields to mrp_bom :

  class plm_relation(osv.osv):
      _name = 'mrp.bom'
      _inherit = 'mrp.bom'

      _columns = {
                  'state': fields.related('product_id','state',type="char",relation="product.template",string="Status",store=False),
                  'engineering_revision': fields.related('product_id','engineering_revision',type="char",relation="product.template",string="Revision",store=False),
                  'description': fields.related('product_id','description',type="char",relation="product.template",string="Description",store=False),
                  'weight_net': fields.related('product_id','weight_net',type="float",relation="product.product",string="Weight Net",store=False),
                  'uom_id': fields.related('product_id','uom_id',type="integer",relation="product.product",string="Unit of Measure",store=False),
                  'child_complete_ids': fields.function(_child_compute, relation='mrp.bom', method=True, string="BoM Hierarchy", type='many2many'),
                 }

  plm_relation()

  And debugging server I can notice that in unix server, on
  osv/fields.py :

  
      def postprocess(self, cr, uid, obj, field, value=None, context=None):
          if context is None:
              context = {}
          result = value
          field_type = obj._columns[field]._type
          if field_type == "many2one":
              # make the result a tuple if it is not already one
              if isinstance(value, (int,long)) and hasattr(obj._columns[field], 'relation'):
                  obj_model = obj.pool.get(obj._columns[field].relation)
                  dict_names = dict(obj_model.name_get(cr, uid, [value], context))
                  result = (value, dict_names[value])

          if field_type == 'binary':
              if context.get('bin_size'):
                  # client requests only the size of binary fields
                  result = get_nice_size(value)
              elif not context.get('bin_raw'):
                  result = sanitize_binary_value(value)

          if field_type == "integer" and value > xmlrpclib.MAXINT:
              # integer/long values greater than 2^31-1 are not supported
              # in pure XMLRPC, so we have to pass them as floats :-(
              # This is not needed for stored fields and non-functional integer
              # fields, as their values are constrained by the database backend
              # to the same 32bits signed int limit.
              result = __builtin__.float(value)
          return result

  Here, the last condition (if field_type == "integer" and value > xmlrpclib.MAXINT) with uom_id field results true (and it shouldn't be, or better it should be evaluated better).
  On Windows server it results false. More precisely value > xmlrpclib.MAXINT changes its evaluation.
  When you're evaluating uom_id type is integer but value is browse_record: browse_record(product.uom, 1).

  I tried to patch it with :
               if isinstance(value, (int,long)):
                   result = __builtin__.float(value)

  instead :
              result = __builtin__.float(value)

  But, of course, is your decision on how to solve it.

  Thanks
  Regards
  Fabio Colognesi

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