Skip to Content
Menu
This question has been flagged
1 Reply
9878 Views

During development for a project, we realised we would need to set up product variants, so I did some testing.

I set up 3 variants of a demo product and everything worked fine and dandy, I could click through them, and also click on the original product to add/edit more variants.

I then processed a sales order for a variant, and it was all good - until I tried to click on the original product in Sales -> Products, I received a traceback ending with keyerror. Thinking it was a conflict with some of our modules, I tried the same steps on a stock install of Odoo.

Turns out there wasn't a conflict, and the error still shows.

2015-01-31 18:18:23,757 8883 INFO Peter werkzeug: 127.0.0.1 - - [31/Jan/2015 18:18:23] "POST /web/dataset/call_kw/product.template/fields_view_get HTTP/1.1" 200 -
2015-01-31 18:18:24,426 8883 ERROR Peter openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
  File "/home/peter/odoo/openerp/http.py", line 530, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/peter/odoo/openerp/http.py", line 567, in dispatch
    result = self._call_function(**self.params)
  File "/home/peter/odoo/openerp/http.py", line 303, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/peter/odoo/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/peter/odoo/openerp/http.py", line 300, in checked_call
    return self.endpoint(*a, **kw)
  File "/home/peter/odoo/openerp/http.py", line 796, in __call__
    return self.method(*args, **kw)
  File "/home/peter/odoo/openerp/http.py", line 396, in response_wrap
    response = f(*args, **kw)
  File "/home/peter/odoo/addons/web/controllers/main.py", line 949, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/home/peter/odoo/addons/web/controllers/main.py", line 932, in _call_kw
    records = getattr(request.session.model(model), method)(*args, **kwargs)
  File "/home/peter/odoo/openerp/http.py", line 900, in proxy
    result = meth(cr, request.uid, *args, **kw)
  File "/home/peter/odoo/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/peter/odoo/openerp/models.py", line 3109, in read
    result = BaseModel.read(records, fields, load=load)
  File "/home/peter/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/home/peter/odoo/openerp/models.py", line 3141, in read
    self._read_from_database(stored)
  File "/home/peter/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/home/peter/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 "/home/peter/odoo/openerp/osv/fields.py", line 1361, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/home/peter/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 "/home/peter/odoo/openerp/fields.py", line 760, in __get__
    self.determine_value(record)
  File "/home/peter/odoo/openerp/fields.py", line 853, in determine_value
    record._prefetch_field(self)
  File "/home/peter/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/home/peter/odoo/openerp/models.py", line 3196, in _prefetch_field
    result = records.read(list(fnames), load='_classic_write')
  File "/home/peter/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/home/peter/odoo/openerp/models.py", line 3141, in read
    self._read_from_database(stored)
  File "/home/peter/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/home/peter/odoo/openerp/models.py", line 3308, in _read_from_database
    vals[f] = res2[vals['id']]
KeyError: 3

NOTE: This error doesn't show if I haven't processed an order containing a variant of the product.

So, is this a bug i should report to Odoo or have I just set things up incorrectly?

Thanks
Peter

 

Avatar
Discard
Author

Surprisingly enough - yes. I just manually changed the code back to original state and the error no longer shows

Best Answer

Issue related to this commit

Avatar
Discard
Author

Thankyou, I contacted Odoo and the fix has been pushed upstream

Related Posts Replies Views Activity
3
Nov 24
5845
3
Sep 24
4398
0
Dec 17
2805
1
Mar 15
3718
1
Mar 15
3455