Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1347 Weergaven

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
apr. 22
8955
0
aug. 25
117
0
aug. 25
115
2
aug. 25
629
0
jul. 25
512