odooopenerp-8odoo-8

Odoo 8 error when trying to open product with multiple attributes


Our Odoo is version 8 and is running on Ubuntu.

When I try to open product which has multiple attributes (colours, sizes) I get KeyError: 57. Other simple products are OK.

Any idea what can cause this problem ?

here is complete traceback:

Odoo Server Error
Traceback (most recent call last):
  File "/opt/odoo/odoo/openerp/http.py", line 530, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo/openerp/http.py", line 567, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo/openerp/http.py", line 303, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/http.py", line 300, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoo/odoo/openerp/http.py", line 796, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo/openerp/http.py", line 396, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo/addons/web/controllers/main.py", line 949, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/odoo/addons/web/controllers/main.py", line 932, in _call_kw
    records = getattr(request.session.model(model), method)(*args, **kwargs)
  File "/opt/odoo/odoo/openerp/http.py", line 900, in proxy
    result = meth(cr, request.uid, *args, **kw)
  File "/opt/odoo/odoo/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/models.py", line 3109, in read
    result = BaseModel.read(records, fields, load=load)
  File "/opt/odoo/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/models.py", line 3141, in read
    self._read_from_database(stored)
  File "/opt/odoo/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/models.py", line 3305, in _read_from_database
    res2 = self._columns[f].get(cr, self._model, ids, f, user, context=context, values=result)
  File "/opt/odoo/odoo/openerp/osv/fields.py", line 1361, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/opt/odoo/odoo/addons/sale/sale.py", line 1283, in _sales_count
    res[template.id] = sum([p.sales_count for p in template.product_variant_ids])
  File "/opt/odoo/odoo/openerp/fields.py", line 760, in __get__
    self.determine_value(record)
  File "/opt/odoo/odoo/openerp/fields.py", line 853, in determine_value
    record._prefetch_field(self)
  File "/opt/odoo/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/models.py", line 3196, in _prefetch_field
    result = records.read(list(fnames), load='_classic_write')
  File "/opt/odoo/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/models.py", line 3141, in read
    self._read_from_database(stored)
  File "/opt/odoo/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo/openerp/models.py", line 3308, in _read_from_database
    vals[f] = res2[vals['id']]
KeyError: 57

Solution

  • I got same error like your log, but I don't know your code details. You should check field type.

    In my case, I used field function.

    I was make mistaken like below:

    rec = obj.browse(cr,...)
    result = {}
    # result[id] = val     # wrong
    result[rec.id] = val   # correct 
    

    I hope this helps..