Odoo Help


How to update the values of "route_ids" through Web API in the "product.template"?

George Kyriakou
on 2/17/15, 5:52 PM 1,066 views

After connecting to the server using "xmlrpc" and following the instructions from here (https://www.odoo.com/documentation/8.0/api_integration.html), I try to change the value of the "route_ids" (Procurement -> Supply Chain Information -> Routes) so none of the three options (Manufacture, Buy, Make To Order) is selected. 

First I take the current values:

>>> models.execute_kw(db, uid, password,
...     'product.template', 'read',
...     [125], {'fields': ['route_ids']})
{'route_ids': [5, 6, 1], 'id': 125}

Then I attempt to update the values:

>>> models.execute_kw(db, uid, password, 'product.template', 'write', 
... [[125], {'route_ids': []}])    

And finally I check whether the values have been updated or not: 

>>> models.execute_kw(db, uid, password,
...     'product.template', 'read',
...     [125], {'fields': ['route_ids']})
{'route_ids': [5, 6, 1], 'id': 125}

Any idea why this does not work? I got the same results, i.e. no change, when I tried to change the 'display_name' but when I tried to change the 'weight_net' everything works fine. Any ideas?

George Kyriakou
On 4/13/15, 6:32 PM

Ok, so the answer is actually heavily dependent on the documentation and has to do with the special way the many2many relationships are managed: https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.write

So in order to delete all the routes you have to do:

models.execute_kw(db, uid, password, 'product.template', 'write', [[id], {'route_ids': [(5, 0, 0)]}])

And in order to add a route (e.g. with route id '1'):

models.execute_kw(db, uid, password, 'product.template', 'write', [[id], {'route_ids': [(4, 1, 0)]}])


Pascal Tremblay

--Pascal Tremblay--
| 5 2 7
Alma, Canada
--Pascal Tremblay--

Pascal Tremblay
On 4/8/15, 1:06 PM

With a XML file :

<record id="stock_lapagept.warehouse_pt" model="stock.warehouse">

<field name="name">La Page PT - PT2warehouse</field>

<field name="code">WHPT</field>

<field name="partner_id" ref="partners_lapagept.partner_pt" />

<field name="company_id" ref="partners_lapagept.company_pt" />

<field name="view_location_id" ref="stock_lapagept.warehouse_loc_pt" />

<field name="wh_input_stock_loc_id" ref="stock_lapagept.input_loc_pt" />

<field name="wh_output_stock_loc_id" ref="stock_lapagept.output_loc_pt" />

<field name="lot_stock_id" ref="stock_lapagept.etagere_sous_sol_pt" />

<field name="route_ids" eval="[ (6, 0, [ref('stock_lapagept.make_to_order_route_pt'), ref('stock_lapagept.drop_shipping_route_pt') , ref('stock_lapagept.buy_from_supplier_route_pt'), ref('stock_lapagept.receipt_in_1_step_route_pt'), ref('stock_lapagept.ship_to_customer_route_pt') ] ) ]" />


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

2 follower(s)


Asked: 2/17/15, 5:52 PM
Seen: 1066 times
Last updated: 4/13/15, 6:33 PM