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

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




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

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!

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
540
0
thg 7 25
474
1
thg 7 25
907
1
thg 7 25
1303
0
thg 6 25
620