I am trying to use the xmlrpc api to Odoo 9.0 following the examples in the Web Service API documentation. I use 'search' to get the IDs of a couple of records. With those IDs I can list the records one at a time using 'read', e.g. models.execute_kw('odoo', 1, 'odoo', 'tidb.text_item', 'read', [2486]) { .... correct values printed } m.execute_kw('odoo', 1, 'odoo', 'tidb.text_item', 'read', [2487]) {.... correct values printed this time also } m.execute_kw('odoo', 1, 'odoo', 'tidb.text_item', 'read', [2486,2487]) Traceback (most recent call last): File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/http.py", line 115, in dispatch_rpc result = dispatch(method, params) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/service/model.py", line 37, in dispatch res = fn(db, uid, *params) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/service/model.py", line 173, in execute_kw return execute(db, uid, obj, method, *args, **kw or {}) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/service/model.py", line 118, in wrapper return f(dbname, *args, **kwargs) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/service/model.py", line 181, in execute res = execute_cr(cr, uid, obj, method, *args, **kw) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/service/model.py", line 170, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/api.py", line 250, in wrapper return old_api(self, *args, **kwargs) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/models.py", line 3193, in read result = BaseModel.read(records, fields, load=load) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/api.py", line 248, in wrapper return new_api(self, *args, **kwargs) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/models.py", line 3216, in read for name in fields: TypeError: 'int' object is not iterable 2017-05-06 04:06:18,452 2966 INFO odoo werkzeug: 127.0.0.1 - - [06/May/2017 04:06:18] "POST /xmlrpc/2/object HTTP/1.1" 200 - If I limit the fields returned using the keyword argument 'fields' like this: models.execute_kw('odoo', 1, 'odoo', 'tidb.text_item', 'read', [2486], {'fields': ['name']}) { ..... correct value returned } But if I try it for more than one record models.execute_kw('odoo', 1, 'odoo', 'tidb.text_item', 'read', [2486,2487], {'fields': ['name']}) Traceback (most recent call last): File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/http.py", line 115, in dispatch_rpc result = dispatch(method, params) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/service/model.py", line 37, in dispatch res = fn(db, uid, *params) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/service/model.py", line 173, in execute_kw return execute(db, uid, obj, method, *args, **kw or {}) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/service/model.py", line 118, in wrapper return f(dbname, *args, **kwargs) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/service/model.py", line 181, in execute res = execute_cr(cr, uid, obj, method, *args, **kw) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/service/model.py", line 170, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/Volumes/Work/Home/UW/.virtualenvs/odoo/lib/python2.7/site-packages/odoo-9.0rc0-py2.7.egg/openerp/api.py", line 250, in wrapper return old_api(self, *args, **kwargs) TypeError: read() got multiple values for keyword argument 'fields' 2017-05-06 04:11:27,110 2966 INFO odoo werkzeug: 127.0.0.1 - - [06/May/2017 04:11:27] "POST /xmlrpc/2/object HTTP/1.1" 200 - These calls follow the documentation quite closely, so I'm at a loss as to what I might be doing wrong. Does the xmlrpc API not function properly with non-singleton recordsets?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
2437
Views
Hello,
To get data in more than one record use
models.execute_kw(db, uid, password, 'res.partner', 'search_read', [[['id', 'in', [Your_ids]]], {'fields': ['field_1', 'field_2', 'field_3'], 'limit': 5})
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up