Odoo Help

Welcome!

This community 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.

0

How to create product.product (variant) using RPC

By
xiaolong97427
on 4/22/16, 9:34 AM 459 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--
815
| 2 1 4
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

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

Prakash Sharma
on 4/22/16, 10:28 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/22/16, 9:34 AM
Seen: 459 times
Last updated: 4/22/16, 10:24 AM