Reputation: 1
I'm working with Odoo 15 and I'm trying to create and complete a manufacturing order programmatically using XML-RPC with Python. I have ensured that both product_qty and qty_producing are set to a value greater than zero. However, when I attempt to change the status of the manufacturing order to 'done', I receive the error: "The quantity to produce must be positive!".
Here is a simplified version of my code:
# Step 1: Create the Manufacturing
Orderproduct_info = models.execute_kw(db, uid, password, 'product.product', 'search_read', [[['default_code', '=', product_ref]]], {'fields': ['id', 'uom_id'], 'limit': 1})product_id = product_info[0]['id']product_uom_id = product_info[0]['uom_id'][0]
mrp_order_id = models.execute_kw(db, uid, password, 'mrp.production', 'create', [{ 'product_id': product_id,
'product_qty': 5.0, # Positive quantity
'product_uom_id': product_uom_id,
'bom_id': False
}])
# Step 2: Confirm the Manufacturing Order & update qty_producing
models.execute_kw(db, uid, password, 'mrp.production', 'action_confirm', [mrp_order_id])models.execute_kw(db, uid, password, 'mrp.production', 'write', [mrp_order_id, {'qty_producing': 5.0}])
# Step 3: Trying to mark the MO as 'Done'
try:
models.execute_kw(db, uid, password, 'mrp.production', 'button_mark_done', [mrp_order_id])
except
Exception as e:
print("Failed to mark MO as done:", str(e))
OUTPUT :Failed to mark MO as done:<Fault 2: 'mrp_production_qty_positive'>
Both product_qty and the intended qty_producing (implicitly, since I'm trying to mark it as done, which would indicate full production) are greater than zero, but I still encounter this error. Is there a step I'm missing in my process, or is there a known issue with setting manufacturing orders to 'done' status via XML-RPC?
Any advice or insights on how to resolve this error would be greatly appreciated. Thank you!
OUTPUT :Failed to mark MO as done: <Fault 2: 'mrp_production_qty_positive'>
Upvotes: 0
Views: 89