Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1283 Näkymät

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
huhtik. 22
8885
2
elok. 25
181
0
heinäk. 25
460
1
heinäk. 25
860
1
heinäk. 25
1283