Skip to Content
Menu
This question has been flagged
2 Replies
5941 Views

Hi,

I'm doing a PHP app that need to retrieve products from Odoo.

I have OpenErp 7.0


I was wondering if the function search_read mentionned in the exemple in the link below, would work with OpenErp 7?

https://www.odoo.com/documentation/8.0/api_integration.html#search-and-read 

$products = $ripcord->execute_kw('myDB', 1, 'myPassword',
                    'product.template', 'search_read',
                    array(
                        array(
                        array('name', 'ilike', 'pixma'),
                        array('type', 'ilike', 'product'),
                    ['fields'=>array('name', 'description'), 'limit'=>5]
                 ))); 


Because I get this error

 Array ( [faultCode] => 'product.template' object has no attribute 'search_read' [faultString] => Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/openerp-7.0-py2.7.egg/openerp/service/wsgi_server.py", line 82, in xmlrpc_return result = openerp.netsvc.dispatch_rpc(service, method, params) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0-py2.7.egg/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0-py2.7.egg/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0-py2.7.egg/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0-py2.7.egg/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0-py2.7.egg/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0-py2.7.egg/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) AttributeError: 'product.template' object has no attribute 'search_read' ) 


And also.. It's taking a lot of time... how can I do to make it a little bit faster?





Avatar
Discard
Author Best Answer

Thank you for the answer.

What do you mean by "web sessions"?

Any idea to make my research a little bit faster?

For now I'm doing a 'search' in product.template model to sort the ID of the products with name like the keyword entered

and then foreach IDs I do a 'read' to retrieve the info.

But it's really slow and I also need fields that are in other models... So I have to do it in many request and it takes a lot of time. And for big request I got timeout after 120s....

This is annoying and the project is due for the end of the week.

Avatar
Discard
Best Answer

Search_read method is available only in v8 so if you will call this method in v7 it will give you error. In  V7 there is search_read method for web sessions.

Avatar
Discard
Related Posts Replies Views Activity
2
Jun 17
11884
0
Jan 16
6023
0
Mar 18
3119
1
Mar 15
7089
2
Mar 15
9149