Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
6763 Lượt xem

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?





Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 6 17
13309
0
thg 1 16
7071
0
thg 3 18
4274
1
thg 3 15
8354
2
thg 3 15
10469