Skip to Content
Menu
This question has been flagged
1 Reply
2280 Views

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




Avatar
Discard
Author Best Answer

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!

Avatar
Discard
Related Posts Replies Views Activity
2
Dec 24
46
1
Dec 24
56
1
Dec 24
55
0
Dec 24
29
0
Dec 24
45