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

I have installed the Community edition of Odoo 11 and am trying to retrieve data through xml-rpc. 

How do I know which objects are available through the api, and which query parameters and their types are available for each object?

In particular I am trying to retrieve all products, and products filtered by category.

the following code

odoo.execute_kw('res.product', 'search', params, function (err, value) {
    if (err) { return console.log(err); }    console.log('Result: ', value);});

returns 

'Object res.product doesn\'t exist' 

 

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

Hi,

Seems you have given wrong model name, there is no table named res.product by default in odoo, the table name for the Products is product.product.

Sample,

models.execute_kw(db, uid, password,
    'res.partner', 'search_read',
    [[['is_company', '=', True], ['customer', '=', True]]],
    {'fields': ['name', 'country_id', 'comment'], 'limit': 5})

Above given is a sample of reading the data from res.partner table based on some search condition.


You can go through this odoo documentation, explaining the same in detail :-  https://www.odoo.com/documentation/11.0/webservices/odoo.html

Thanks

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

For those interested/having the same question:

The model (or objects) correspond to the database table names. 

There doesn't seem to be any abstraction/controller logic provided by the xml/rpc layer.

You can view the table name and table fields in the UI by activating the debug mode (add ?debug=1 to the url),

and select view fields from the debug menu.  

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 2 25
18
2
thg 3 15
6472
0
thg 3 15
3543
1
thg 3 15
3417
3
thg 5 24
4835