Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
3847 Visualizações

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
Cancelar
Melhor resposta

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
Cancelar
Autor

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.

Publicações relacionadas Respostas Visualizações Atividade
0
jan. 22
2159
2
mai. 17
11095
2
nov. 22
3401
0
jul. 22
1505
1
jan. 22
11216