Issue Parts to a Work Order
When parts are issued against a maintenance work order, the stock movement and the job are linked: you can see what each repair consumed, what it cost, and which work orders drove a part's usage.
This lesson uses the Machine 1 - Coolant leak work order from Raise a One-Time Work Order. If you haven't taken the Maintenance course, read along.
Issue script
issuePartToWorkOrder.py: issues a part from the Parts Room to a work order by name, then lists every part issued to it.
Issue hose to the coolant leak work order
- In Maintenance → Work Orders, note the coolant leak's work order number, such as
MWO00001. - Open
issuePartToWorkOrder.pyin the Ignition Designer Script Console. - Set
workOrderEventNameto your work order number,partNumbertoCF-HOSE-075, andquantityto6. - Run the script. It looks up the IDs it needs, calls
issuePartToWorkOrderEvent, and prints the parts used on the work order. - In Inventory → Parts, expand
CF-HOSE-075. On hand is now 19, and the issue references the work order.
The script passes two assets: the inventory asset the hose came from (Parts Room) and the asset it was used on (Machine 1). That's what lets you report parts consumption by machine as well as by storeroom.