Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
titleCheck Work Order Function
linenumberstrue
def checkWorkOrder(woName, matName):
	filter = system.mes.object.filter.createFilter()
	filter.setMESObjectTypeName('WorkOrder')
	filter.setMESObjectNamePattern(woName)
	list = system.mes.searchMESObjects(filter)
		
	if list.size() == 0:
		matLink = system.mes.getMESObjectLinkByName('MaterialDef', matName)
		obj = system.mes.workorder.createMESWorkOrder(woName, matLink)
		system.mes.saveMESObject(obj)
	else:
		woObj = list.get(0).getMESObject()
		matObj = system.mes.loadMESObject(matName, 'MaterialDef')
		if woObj.getMaterialRef().getMESObject() != matObj:
			woObj.setMaterialRef(matObj)	
			system.mes.saveMESObject(woObj)
		
	return system.mes.workorder.getMESWorkOrder(woName)

...