Skip to main content

system.kanoa.order.addProductionOrder

Requires kanoaOPS license

Description

Add a production order

Syntax

addProductionOrder(woInfo, userId)

Parameters:
  • woInfo (dict):
  • userId (int):

  • Returns:
  • workOrderId (int)
  • Dictionary

    ParameterTypeRequiredNotes
    workOrderNamestring
    modeIdintGenerally set to production mode, but could be any mode such as the modeId for experimental as an example
    itemIdint
    itemUnitIdint
    assetIdint Specifies an asset for this order. Can be none or key not passed in.
    workOrderSourceIdint
    reqdQtyfloat
    dueDatedatetime
    workOrderStatusIdint
    notestring
    updateClientsboolIf 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)