Skip to Content
Menu
This question has been flagged
1 Reply
2699 Views

I'm wondering if it's possible to write data into the relation table trough xmlrpc calls? I've got a web form that creates a user for a odoo demo instance. I'm trying to add groups to a that user. I get the group ids from the res.groups table. Now I need to add the records to the relation table res.groups.users.rel and I know I just can't directly write into it.

If it would be a local instance I could just do user.groups_id = (the id for the group that manages employees)

Is it possible to insert m2m relations trough xmlrpc calls? If it is, how?

Avatar
Discard
Best Answer

You can write as following to set groups in user.

$info = ripcord::client('https://demo.odoo.com/start')->start();

$common = ripcord::client($url . '/xmlrpc/2/common');

$models = ripcord::client("$url/xmlrpc/2/object");

$uid = $common->authenticate($db, $username, $password, array());

$user_id = 1;

$group_id = 5;

$models->execute_kw($db, $uid, $password, 'res.users', 'write',

    array(array($user_id),array(

         'groups_id'=>array(array(4,$group_id))

)));


Avatar
Discard
Author

I found this post on stackoverflow allready. tried with the touple with the 4 command, but it won't work and I just cant figure out why. so this copy paste code that is for php doesn't help me.

Can you please paste your code here, so I can help you for that, because above code is working properly.

Related Posts Replies Views Activity
0
Jan 22
1468
2
May 17
10098
2
Nov 22
2436
0
Jul 22
731
1
Jan 22
9931