system.kanoa.order.addProductionOrder
Description
Add a production orderSyntax
addProductionOrder(woInfo, userId)Parameters:
Returns:
Dictionary
Parameter | Type | Required | Notes |
---|---|---|---|
workOrderName | string | ||
modeId | int | Generally set to production mode, but could be any mode such as the modeId for experimental as an example | |
itemId | int | ||
itemUnitId | int | ||
assetId | int | Specifies an asset for this order. Can be none or key not passed in. | |
workOrderSourceId | int | ||
reqdQty | float | ||
dueDate | datetime | ||
workOrderStatusId | int | ||
note | string | ||
updateClients | bool | If set to false, clients will not be automatically updated. If missing or true clients will be updated, useful when large import is taking place. |
Code Examples
itemUnitId = system.kanoa.utilities.getFieldValue('itemUnitId', system.kanoa.item.getItemUnits({'itemUnitName': 'lbs'}))
if itemUnitId is None: itemUnitId = system.kanoa.item.addItemUnit(uom, userId)
workOrderSourceId = system.kanoa.utilities.getFieldValue('workOrderSourceId', system.kanoa.order.getProductionOrderSource({'workOrderSourceName': 'ERP'}))
modeId = system.kanoa.utilities.getFieldValue('modeId', system.kanoa.asset.getModes({'modeName': 'Production'}))
woStates = system.kanoa.utilities.convertDatasetToDict(system.kanoa.order.getProductionOrderStates({}), 'workOrderStatusName', 'workOrderStatusId')
itemInfo = system.kanoa.utilities.convertDatasetRowToJSON(system.kanoa.item.getItems({'itemName': 'sausages'}),0)
workOrderStatusId = woStates['Released']
dueDate = system.date.now()
userId = system.kanoa.security.getIDPUserId({'userName': 'SYSTEM'})
woInfo = {'workOrderName': 'WO123', 'modeId': modeId, 'itemId': itemInfo['itemId'], 'itemUnitId': itemUnitId, 'assetId': None, 'workOrderSourceId':workOrderSourceId, 'reqdQty': 100.0, 'dueDate': dueDate, 'workOrderStatusId': woStates['Released'], 'note': None}
workOrderId = system.kanoa.order.addProductionOrder(woInfo, userId)