Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
9323 Lượt xem

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': []}])    
True

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?

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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)]}])

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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') ] ) ]" />

</record>

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 6 22
5662
1
thg 10 24
2925
2
thg 12 22
3113
5
thg 9 19
7897
0
thg 4 18
2483