コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
3384 ビュー

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
8月 25
539
0
7月 25
474
1
7月 25
907
1
7月 25
1303
0
6月 25
620