Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1284 Prikazi

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:
Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
2
apr. 22
8885
2
avg. 25
181
0
jul. 25
460
1
jul. 25
860
1
jul. 25
1283