Odoo Help


How to create product.product (variant) using RPC

on 4/22/16, 9:34 AM 1,045 views


I need to create a Blue Color T-shirt using webservice (RPC)

I can create the product,_template(T-shirt), the product_attribute_line (Color) the product_attribute_value (Blue).

But I can't create the Blue-color-TShirt. I can't update the field  product_attribute_line.value_ids. I've tried to set it during the creation of a product_attribute_line record or after using a write method. Both didn't work. 

What is the correct way to create the product variant using RPC in Odoo v9 ?

Prakash Sharma
On 4/22/16, 9:55 AM

i updated the  product.attribute.line  [in php ripcode[ this way:

$existing_prodid = 59;
$existing_attribute_id = 2;
$existing_value_id = 4; 
$product_attribute_line = $models->execute($db, $uid, $password,
array('product_tmpl_id' => $existing_prodid,

In  python [using  xmlrpclib ]:

attibute_line = models.execute_kw(dbname, uid, password,

'product.attribute.line', 'create',[{

'product_tmpl_id':59,'attribute_id':2,'value_ids':[(6,0,[4])]}] )

 hope this may help you.

Thank you very much Sharma. Indeed it helps. But I can't figure out what is the structure of value_ids ? How did you find it ? Or where shall I search to find the answer. Cause same problem may happened again for other objects that I would lilke to create

on 4/22/16, 10:14 AM

To be more accurate on my comment, I don't understand the constant: 6 and 0 in the value_ids. Also, please note that I was able to create my product variant thanks to your : 6,0,array($existing_value_id). So I will marked the question as answered. But I will really appreciate if you can guide on how to not get stuck in this situation. Shall I start by looking at the python method triggered by the call of /web/dataset/call_kw ?

on 4/22/16, 10:23 AM

i have used (6,0,[ids]),it's the syntax of creating many2many try this link http://stackoverflow.com/questions/31853402/filling-many2many-field-odoo-8 and https://www.odoo.com/documentation/8.0/reference/orm.html

webkul, Prakash Sharma
on 4/22/16, 10:26 AM

here is my explanation http://stackoverflow.com/questions/36643092/create-a-record-into-many2many-table-using-web-service-api-in-odoo-8/36709180#36709180

webkul, Prakash Sharma
on 4/22/16, 10:28 AM
Sergio Cloud
On 3/22/17, 8:37 AM

Hi, I'm creating attribute lines with the following params: 

{ product_tmpl_id: 75, attribute_id: 13, value_ids: [(6,0,[199])] }

The attribute line has been created but the value_ids field is empty:

{ create_uid: [ 1, 'Administrator' ],    create_date: '2017-03-22 12:21:23',    __last_update: '2017-03-22 12:22:54',    value_ids: [],    write_uid: [ 1, 'Administrator' ],    product_tmpl_id: [ 75, 'todojunto' ],    attribute_id: [ 13, 'Talla' ],    write_date: '2017-03-22 12:22:54',    display_name: 'Talla',    id: 84 }

I don't know what I'm doing wrong... Any solution?


The right structure is:

value_ids: [[6, 0,[191,201]]]

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.


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

1 follower(s)


Asked: 4/22/16, 9:34 AM
Seen: 1045 times
Last updated: 3/22/17, 8:37 AM