Odoo Help

0

Unable to set category_id/tags/labels when creating a Customer via Web Services/XMLRPC

By
alexk1r
on 2/11/16, 8:10 AM 438 views

I'm trying to create a customer and set the tag. This is what I'm doing:

$customer = $this->client->execute_kw($this->db, $this->uid, $this->pass,                       
 'res.partner', 'create',
 [
    [
        'is_company' => 1,
        'x_external_id' => $data['id'],
        'name' => $data['name'],
        'parent_id' => 1, //cf id
        'category_id' => [1], //tags
        'street' => $data['line1'],
        'city' => $data['town'],
        'state_id' => $this->_searchCounty($data['county_name']),
        'zip' => $data['postcode'],
        'website' => $data['website'],
        'phone' => $data['telephone'],
        'email' => $data['email'],
        'property_account_receivable' => 30,
        'property_account_payable' => 41,
        'customer' => true,
        'supplier' => true,
        'active' => true,
        'opt_out' => 1,
        'notify_email' => 'none'
    ]
]);

I would imagine passing an array with correct Id should have been enough, since this is how the tags show up when you read the record. But when the record is created, it doesn't have any tags attached to it, while all other passed information is present. Is there anything special about setting the tags via web services?

1
Jo
On 2/12/16, 3:55 AM

Hi Alex,

category_id / Tags is many2many field. so pass many2many values like following this,

category_id => [[6, 0, [1]]],
I hope this will help you.

Thanks! I thought it something like that. Actually it would be 'category_id' => [[6, 0, [1]]] in my case. A quick search many2many and xmlrpc brought me to: https://www.odoo.com/forum/help-1/question/how-to-format-value-for-a-many2many-field-thru-xml-rpc-10877

alexk1r
on 2/12/16, 4:11 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 2/11/16, 8:10 AM
Seen: 438 times
Last updated: 4/29/16, 11:23 PM