This question has been flagged
1 Reply
2040 Views

Hi!


I want to update the category_id of the partner via XMLRPC but it doesn't work... I don't know what I'm doing wrong, so, I need help...


The code (in PHP) is this. For example, I want to update the user with id = 33 to put category_id = 6:

$fields = ['category_id' => 6];
XML_RPC::CallMethod($this->data['oobj'], 'execute_kw', [$this->data['db'], $this->wusr, $this->ad['psw'], 'res.partner', 'write', [[33], $fields]]);

Also, I tried to put in the category_id in an array, but the same:

$fields = ['category_id' => [6]];
XML_RPC::CallMethod($this->data['oobj'], 'execute_kw', [$this->data['db'], $this->wusr, $this->ad['psw'], 'res.partner', 'write', [[33], $fields]]);

Finally, I tried to empty all the categories of the partner, but don't do that:

$fields = ['category_id' => ""];
XML_RPC::CallMethod($this->data['oobj'], 'execute_kw', [$this->data['db'], $this->wusr, $this->ad['psw'], 'res.partner', 'write', [[33], $fields]]);

Where is the problem?

Avatar
Discard
Author Best Answer

Ok, I see that category_id is a many2many field and I see that the update any field of this it's different (with array). So, for update, you have to do this:

$fields = ['category_id' => [[6, 0, [1]]]];
XML_RPC::CallMethod($this->data['oobj'], 'execute_kw', [$this->data['db'], $this->wusr, $this->ad['psw'], 'res.partner', 'write', [[33], $fields]]);

It works :)

Avatar
Discard