تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
10050 أدوات العرض

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?

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

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

الصورة الرمزية
إهمال
أفضل إجابة

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>

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
يونيو 22
6379
1
أكتوبر 24
3902
2
ديسمبر 22
3882
5
سبتمبر 19
8264
0
أبريل 18
2483