尝试打开具有多个属性的产品时出现Odoo 8错误

时间:2022-01-29 15:46:02

Our Odoo is version 8 and is running on Ubuntu.

我们的Odoo是版本8,在Ubuntu上运行。

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

当我尝试打开具有多个属性(颜色,大小)的产品时,我得到KeyError:57。其他简单的产品都可以。

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

1 个解决方案

#1


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..

我希望这有帮助..

#1


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..

我希望这有帮助..