Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1282 Ansichten

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Apr. 22
8885
2
Aug. 25
181
0
Juli 25
460
1
Juli 25
860
1
Juli 25
1283