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

Hi 

I wanted to create a M.O. using XMLRPC API, see code snippet below:

models.execute_kw(db, uid, password, 
'mrp.production', 'create',
[{'product_id':1579,
'company_id':1,
'consumption': 'flexible',
'date_planned_start': '2021-08-01 09:00:00',
'location_dest_id': 8,
'location_src_id': 8,
'picking_type_id': 13,
'product_qty':1,
'product_uom_id':1,
'move_finished_ids': 301
}])

As part of the creation of the M.O. I want to add "301" to the move_finished_ids, this is the id of a stock.move record. I couldn't get this to work. I figured this might be because it is an one-to-many field so I followed the other posts and tried a few things, none seems to work.


Could anyone shed me the light of how to assign values to move_finished_ids when creating a new M.O. record?


Cheers

Yuan




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

I have found a workaround to my own post.

Instead of trying to assign a value to move_finished_ids field at the creation of a production/manufacturing order, I firstly created a production/manufacturing order without assigning move_finished_ids value and then updated the record later with the desired move_finished_ids value. See code snippet below:

#Step 1 - Create a M.O. 
newMO = {
'product_id': 1579,
'company_id': 1,
'consumption': 'flexible',
'date_planned_start': '2021-08-01 09:00:00',
'location_dest_id': 8,
'location_src_id': 8,
'picking_type_id': 13,
'product_qty': 1,
'product_uom_id': 1
}
models.execute_kw(db, uid, password, 'mrp.production', 'create', [newMO])

#Step 2 - Update move_finished_ids (in this case 330) in Manufacturing Order 71.
iD = 71
attr = {
'move_finished_ids': [330]
}

models.execute_kw(db, uid, password, 'mrp.production', 'write', [[iD], attr]

This worked perfectly fine in my case. If you know how to combine two steps into one, please do let me know!

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
أغسطس 25
241
0
يوليو 25
463
1
يوليو 25
867
1
يوليو 25
1288
0
يونيو 25
590