问题
I need to create a record in mail_vote table(many2many) with fields message_id and user_id Using Web service API. I found a document here: https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.write . But i don't know how to use that in my code. Any solution please.
回答1:
Below i am posting the code snippet for associating (6,0,[ids])]
the Many2many record in product.attribute.line
.
In Php here i have used
ripcord
for this task.
$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)))
))
Here the product.attribute.line
have have Many2many relation with product.attribute.value
So this is how i associated a records for value_ids
['value_ids'=>array(array(6,0,array($existing_value_id)))
].
In python i have used
xmlrpclib
for this task.
attibute_line = models.execute_kw(dbname, uid, password,
'product.attribute.line', 'create',
[{'product_tmpl_id':59,'attribute_id':2,'value_ids':[(6,0,[4])]}] )
I hope this may help in your case
来源:https://stackoverflow.com/questions/36643092/create-a-record-into-many2many-table-using-web-service-api-in-odoo-8