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

I am  trying to create a new customer via XML-RPC. I followed the tutorial here

https://www.odoo.com/documentation/8.0/api_integration.html

I am able to create new res.Partner and fill all the contact information. I failed with setting the Tags (category_id). 

$resp = $models->execute_kw($db, $uid, $password, 'res.partner', 'write',
    array(array($userID), 
        array('category_id'=>array(4,array($tagID),0))
        ));

The question is how to set many2many relation using PHP and XML-RPC? I am aware of the API here https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.write but there is no description how to call it from PHP.

Ảnh đại diện
Huỷ bỏ
Tác giả

At least some hint would be enought

Câu trả lời hay nhất

The JSON for category_id if $tagID == 100 should be:

 "category_id": [[4, [100], 0]]


So I believe that your PHP code should have an additional array() as shown below

$resp = $models->execute_kw($db, $uid, $password, 'res.partner', 'write',
array(array($userID),
array(array('category_id'=>array(4,array($tagID),0)))
));

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

TO Garry: As I wrote in my question I followed the integration API but there is no tutorial how to set many2many property.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 1 21
15565
0
thg 8 23
5055
1
thg 2 21
11395
4
thg 6 20
6296
1
thg 2 19
7837