Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Some return values are not supported by the XML-RPC interface

By
Julian Hammer
on 6/24/14, 11:23 AM 1,169 views

product_pricelist.price_get_multi() returns a dictionary with integer as keys. Unfortunatly this is not supported by xmlrpclib.

>>> try:
...     oerp.execute('product.pricelist', 'price_get_multi', [1], [(700, 1, 0)], {'lang': 'de_DE'})
... except Exception as e:
...     print e.oerp_traceback
...

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/service/wsgi_server.py", line 83, in xmlrpc_return
    response = xmlrpclib.dumps((result,), methodresponse=1, allow_none=False, encoding=None)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1085, in dumps
    data = m.dumps(params)
  File "/usr/lib/python2.7/xmlrpclib.py", line 632, in dumps
    dump(v, write)
  File "/usr/lib/python2.7/xmlrpclib.py", line 654, in __dump
    f(self, value, write)
  File "/usr/lib/python2.7/xmlrpclib.py", line 733, in dump_struct
    raise TypeError, "dictionary key must be string"
TypeError: dictionary key must be string

I can provide a patch that converts the keys to strings accordingly. The same is done by the json module.

Should I submit a patch or is there a better way to access the function using oerplib?

0
Julian Hammer
On 8/18/14, 7:42 AM

One needs to use the new JSON RPC interface. 

# price_get_multi(self, cr, uid, pricelist_ids, products_by_qty_by_partner, context=None)
>>> cnt = oerplib.rpc.ConnectorJSONRPC('SERVER_NAME', port=8069)
>>> cnt.proxy.web.session.authenticate(db='DATABASE_NAME', login='USERNAME', password='PASSWORD')
>>> r = cnt.proxy.web.dataset.call(model='product.pricelist', method='price_get_multi',
...                                args=[[1], [(700, 1, None)], {'uid': 1}])
>>> if 'error' not in r:
...     print r
... else:
...     print r['error']['data']['debug']
{u'jsonrpc': u'2.0', u'id': 154493018, u'result': {u'item_id': 1, u'700': {u'1': 0.06}}}

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/24/14, 11:23 AM
Seen: 1169 times
Last updated: 3/16/15, 8:10 AM