Skip to main content

A Reorder Report by Script

The Needs Reordering widget shows the parts to buy on a dashboard. Purchasing may want that list in an email or a file instead. system.kanoa.inventory.getPartInventoryStock returns the same information to a script.

It returns a dataset with one row per part and storeroom. Each row joins the stock balance with the stocking policy. Pass filters in a dictionary, or an empty dictionary for every row. The filters you need are:

FilterValueMeaning
isStockedTrueOnly parts with an active stocking policy
isBelowReorderThresholdTrueOnly parts below their reorder point
inventoryAssetName or inventoryAssetPath'Parts Room' or the full pathOnly one storeroom

Each row has columns such as partNumber, inventoryAssetName, quantityOnHand, quantityOnOrder, reorderPointQty, reorderQty, uomCode and isBelowSafetyStock.

Reference Materials: getPartInventoryStock

Returns a combined view of part inventory balance and policy data for the inv.vwPartInventoryStocking view � a joined "stock" record per part/bin that merges on-hand and on-order quantities with the configured inventory policy (reorder threshold, safety stock, stocked flag, etc.). All parameters are optional filters passed in a single dictionary; omitting paramsDict keys, or passing an empty dictionary, returns the full unfiltered result set.


Parameters​

paramsDict Dictionary

- hasOnHandBoolean
- hasOnOrderBoolean
- inventoryAssetIdInteger
- inventoryAssetNameString
- inventoryAssetPathString
- inventoryAssetTypeNameString
- isBelowReorderThresholdBoolean
- isBelowSafetyStockBoolean
- isStockedBoolean
- partCategoryPathString
- partIdInteger
- partInventoryBalanceIdInteger
- partInventoryPolicyIdInteger
- partNumberString

Returns​

data pyDataset


Example​

paramsDict = {
'inventoryAssetName': 'Parts Room',
'isBelowReorderThreshold': True,
'isStocked': True,
}

data = system.kanoa.inventory.getPartInventoryStock(paramsDict)
data = system.kanoa.utilities.convertDatasetToJSON(data)

for i, row in enumerate(data):
print 'Row %i'%i
for k,v in row.items():
print k,v

break #Just limiting to returning the columns from the first record for display purposes
>>>
Row 0
partId 26
inventoryAssetPath Kanoa Box Co\Warehouse\Parts Room
lastUpdated Tue Jun 09 14:53:05 UTC 2026
isBelowSafetyStock 1
partInventoryBalanceId None
quantityOnOrder 0.0
quantityOnHand 0.0
partInventoryPolicyId 6
countFrequencyDays 60
inventoryAssetId 2968
inventoryPartPath Kanoa Box Co\Warehouse\Parts Room\Bearings\AAA111
partCategoryPath Bearings
inventoryAssetTypeName Storage Location
quantityAvailable 0.0
defaultUomId 1
uomCode EA
partPath Bearings\AAA111
inventoryAssetName Parts Room
reorderPointQty 50.0
isStocked True
quantityReserved 0.0
isBelowReorderThreshold 1
uomName Each
partNumber AAA111
maxQty 100.0
reorderQty 50.0
safetyStockQty 40.0
minQty 10.0
>>>
Print the reorder list
  1. In Inventory → Parts, check that CF-FLT-COOL10 has 2 on hand, below its reorder point. You did this in Adjust Stock and Find Reorders.

  2. In the Ignition Designer, open the Script Console and run:

    rows = system.kanoa.utilities.convertDatasetToJSON(
    system.kanoa.inventory.getPartInventoryStock({
    'inventoryAssetName': 'Parts Room',
    'isStocked': True,
    'isBelowReorderThreshold': True,
    }))

    for row in rows:
    print row.get('partNumber'), row.get('quantityOnHand'), row.get('reorderPointQty'), row.get('reorderQty'), row.get('uomCode')
  3. Check the output. CF-FLT-COOL10 is listed with 2.0 on hand, and its reorder point and reorder quantity.

  4. Receive some filters into the Parts Room so it rises above its reorder point, and run the script again. The part drops off the list.

Turn it into a report​

Put the query in a project script library function that returns text, so any caller can use it:

def reorderText(storeroomName):
"""
One line per part to reorder. Returns None when nothing needs ordering.
"""
rows = system.kanoa.utilities.convertDatasetToJSON(
system.kanoa.inventory.getPartInventoryStock({
'inventoryAssetName': storeroomName,
'isStocked': True,
'isBelowReorderThreshold': True,
}))
if not rows:
return None

lines = ['Part, On hand, On order, Reorder qty, UOM']
for row in rows:
lines.append('%s, %s, %s, %s, %s' % (row.get('partNumber'), row.get('quantityOnHand'),
row.get('quantityOnOrder'), row.get('reorderQty'), row.get('uomCode')))
return '\n'.join(lines)

Save the library as inventoryReports in your project, then call inventoryReports.reorderText('Parts Room') from the Script Console to check it.

Run it on a schedule​

A gateway timer script can call inventoryReports.reorderText('Parts Room') once a day. If it returns text, the script sends it to purchasing with Ignition's email function, or writes it to a file. If it returns None, it does nothing.

note

Scheduling, email and file writing are standard Ignition features, not Kanoa functions. See the Ignition documentation for gateway timer scripts and system.net.sendEmail.

Only report what changed

A daily email that repeats the same parts becomes noise. Filter with hasOnOrder set to False to skip parts that already have an order open.

You built a script that finds every stocked part below its reorder point, turned it into a report function, and learned how to run it on a schedule.