def getPlannedEndDateByJobTicketProperty(record): # план заполняется по номерку, a номерок может подбираться автоматом if record: action = CAction(record=record) actionType = action.getType() propertyTypeList = actionType.getPropertiesById().values() for propertyType in propertyTypeList: if type(propertyType.valueType ) == CJobTicketActionPropertyValueType: property = action.getPropertyById(propertyType.id) jobTicketId = property.getValue() if jobTicketId: db = QtGui.qApp.db date = forceDate( db.translate('Job_Ticket', 'id', jobTicketId, 'datetime')) jobId = forceRef( db.translate('Job_Ticket', 'id', jobTicketId, 'master_id')) jobTypeId = forceRef( db.translate('Job', 'id', jobId, 'jobType_id')) ticketDuration = forceInt( db.translate('rbJobType', 'id', jobTypeId, 'ticketDuration')) return date.addDays(ticketDuration) return None
def setProbeResultToActionProperties(tissueJournalId, testId, result): db = QtGui.qApp.db tableAction = db.table('Action') tableActionPropertyType = db.table('ActionPropertyType') queryTable = tableAction.innerJoin( tableActionPropertyType, tableActionPropertyType['actionType_id'].eq( tableAction['actionType_id'])) cond = [ tableAction['takenTissueJournal_id'].eq(tissueJournalId), tableActionPropertyType['test_id'].eq(testId) ] actionRecordList = db.getRecordList(queryTable, 'Action.*', cond) for actionRecord in actionRecordList: needSave = False action = CAction(record=actionRecord) actionType = action.getType() propertyTypeItemsList = actionType.getPropertiesById().items() for propertyTypeId, propertyType in propertyTypeItemsList: if propertyType.testId == testId: property = action.getPropertyById(propertyTypeId) if not propertyType.isVector: property.setValue( propertyType.convertQVariantToPyValue(result)) needSave = True if needSave: action.save(idx=forceInt(actionRecord.value('idx')))