Skip to main content

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
  1. In Maintenance → Work Orders, note the coolant leak's work order number, such as MWO00001.
  2. Open issuePartToWorkOrder.py in the Ignition Designer Script Console.
  3. Set workOrderEventName to your work order number, partNumber to CF-HOSE-075, and quantity to 6.
  4. Run the script. It looks up the IDs it needs, calls issuePartToWorkOrderEvent, and prints the parts used on the work order.
  5. 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.

Reference Materials: Issue Against a Maintenance Work Order

Issue Against a Maintenance Work Order​

Parts consumed during a maintenance activity can be tracked directly against the work order event. This provides full traceability between stock consumption and maintenance history.

inventoryTransactionId, err = system.kanoa.inventory.issuePartToWorkOrderEvent({
'partId': partId,
'quantity': 2,
'workOrderEventId': workOrderEventId,
'inventoryAssetId': warehouseAssetId,
'assetId': maintainedAssetId,
'usedBy': technicianUserId,
'unitCost': 3.75,
}, userId)

To retrieve all parts consumed against a set of work order events:

data = system.kanoa.inventory.getPartsUsedByWorkOrderEvents({
'workOrderEventId': workOrderEventId,
})