Reputation: 17
I'm creating the order like this:
new_manufacturing = models.execute_kw(db, uid, password,
'mrp.production', 'create',
[{'name':'M0001','product_id':155,'product_uom':1, 'bom_id':54, 'state':'draft'
}],)
and then make it ready to production,then production started,
reserve_materials = models.execute_kw(db, uid, password,
'mrp.production', 'force_production',
[[new_man],{'context':False}])
start_production = models.execute_kw(db, uid, password,
'mrp.production', 'action_in_production',
[[new_man],{'context':False}])
but when I do:
consume = models.execute_kw(db, uid, password,
'mrp.production', 'action_produce',
[new_manufacturing,1.00,['consume_produce']])
it doesn't consume the bill of materials and the product does NOT appear in inventory. (even though the message Production produced is there).
P.S. I need to use the webservice API as I don't have aces to change the code on server printscreen from app
Upvotes: 0
Views: 1450
Reputation: 6295
Assuming that you are using v9 or higher version here. Note here that you are using v9 MRP and that has workflow associated to each record and you are calling direct Object mrp.production
methods to manipulate record but it will fail reason being workflow Engine will reject your operation that you trying to by-pass. Below ic correct code that calls workflow and also it call consume wizard and trigger it correct to consume it:
# Create a Production record
new_manufacturing = models.execute_kw(db, uid, password,
'mrp.production', 'create',
[{'product_id':34,'product_uom':1, 'bom_id':4, 'product_qty': 1.0}],)
# Call workflow to confirm production.
models.exec_workflow(db, uid, password, "mrp.production", 'button_confirm', new_manufacturing)
# Force reserve dreictly as its not part workflow for mrp
models.execute_kw(db, uid, password, 'mrp.production', 'force_production', [new_manufacturing])
#prepare context consume product wizard.
context={'active_id': new_manufacturing, 'active_ids': [new_manufacturing], "active_model": "mrp.production"}
# Create a consume wizar object
produce_id = models.execute_kw(db, uid, password,
'mrp.product.produce', 'create',
[{'product_id':34, 'product_qty': 1.0, 'mode': 'consume_produce'}, context])
# execue Consume wizard to trigger final workflow record.
models.execute_kw(db, uid, password, 'mrp.product.produce', 'do_produce', [[produce_id], context])
also while creating mrp.prodution do not pass state or name are they have default value generate by system.
Upvotes: 0