Odoo Help

0

How to create product.product (variant) using RPC

By
xiaolong97427
on 4/22/16, 9:34 AM 659 views

Gi,

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 ?

0

Prakash Sharma

--Prakash Sharma--
823
| 3 1 5
Delhi, India
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

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,
'product.attribute.line','create',
array('product_tmpl_id' => $existing_prodid,
'attribute_id'=>$existing_attribute_id,
'value_ids'=>array(array(6,0,array($existing_value_id)))))


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

xiaolong97427
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 ?

xiaolong97427
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
0
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?


SOLVED!

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.

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

1 follower(s)

Stats

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