Exemplo n.º 1
0
    def search(self):
        db = QtGui.qApp.db
        action_tbl = db.table('Action')
        action_template_tbl = db.table('ActionTemplate')
        tbl = action_template_tbl.leftJoin(
            action_tbl, action_template_tbl['action_id'].eq(action_tbl['id']))
        cond = [action_template_tbl['deleted'].eq(0)]
        if self.props['name']:
            cond.append(action_template_tbl['name'].like('%%%s%%' %
                                                         self.props['name']))
        if self.props['action_type']:
            cond.append(tbl[''])
        if self.props['sex']:
            cond.append(action_template_tbl['sex'].eq(self.props['sex']))
        if self.props['speciality']:
            cond.append(action_template_tbl['speciality_id'].eq(
                self.props['speciality']))
        if self.props['person']:
            cond.append(action_template_tbl['owner_id'].eq(
                self.props['person']))

        idList = QtGui.qApp.db.getIdList(tbl, action_template_tbl['id'], cond)
        idCount = len(idList)
        self.tblRecords.setIdList(idList)
        self.lblRecordsCount.setText(formatRecordsCount(idCount))
        if idCount == 0:
            self.setFocusToWidget(self.edtCode)
        elif idCount == 1:
            self.foundId = idList[0]
            self.accept()
Exemplo n.º 2
0
 def select(self, props=None):
     db = QtGui.qApp.db
     table = self.modelTable.table()
     groupId = self.currentGroupId()
     groupCond = db.translate(table, 'id', groupId, 'code')
     className = self.currentClass()
     cond = [table['group_code'].eq(groupCond)]
     cond.append(table['deleted'].eq(0))
     cond.append(table['class'].eq(className))
     idList = QtGui.qApp.db.getIdList(table.name(), 'id', cond, self.order)
     self.lblCountRows.setText(formatRecordsCount(len(idList)))
     return idList
Exemplo n.º 3
0
 def updateMotionsList(self, currentId=None):
     filter = self.motionsFilter
     db = QtGui.qApp.db
     table = db.table('StockMotion')
     tableItems = db.table('StockMotion_Item')
     cond = [
         table['deleted'].eq(0),
         db.joinOr([
             table['supplier_id'].eq(QtGui.qApp.currentOrgStructureId()),
             table['receiver_id'].eq(QtGui.qApp.currentOrgStructureId())
         ])
     ]
     if filter.supplierId:
         #            cond.append(table['supplier_id'].inlist(getOrgStructureDescendants(filter.orgStructureId)))
         cond.append(table['supplier_id'].eq(filter.supplierId))
     if filter.receiverId:
         #            cond.append(table['supplier_id'].inlist(getOrgStructureDescendants(filter.orgStructureId)))
         cond.append(table['receiver_id'].eq(filter.receiverId))
     if filter.begDate:
         cond.append(table['date'].ge(filter.begDate))
     if filter.endDate:
         cond.append(table['date'].lt(filter.endDate.addDays(1)))
     if filter.note:
         cond.append(table['note'].like(filter.note))
     if filter.nomenclatureId or filter.financeId:
         subcond = [tableItems['master_id'].eq(table['id'])]
         if filter.nomenclatureId:
             subcond.append(tableItems['nomenclature_id'].eq(
                 filter.nomenclatureId))
         if filter.financeId:
             subcond.append(tableItems['finance_id'].eq(filter.financeId))
         cond.append(db.existsStmt(tableItems, subcond))
     idList = db.getIdList(table,
                           idCol=table['id'],
                           where=cond,
                           order='date DESC, id DESC')
     self.tblMotions.setIdList(idList, currentId)
     self.lblMotions.setText(formatRecordsCount(len(idList)))
Exemplo n.º 4
0
 def updateRTMsList(self, currentId=None):
     filter = self.RTMsFilter
     db = QtGui.qApp.db
     table = db.table('StockRequisition')
     tableItems = db.table('StockRequisition_Item')
     cond = [
         table['deleted'].eq(0),
         table['supplier_id'].eq(QtGui.qApp.currentOrgStructureId()),
     ]
     if filter.orgStructureId:
         cond.append(table['recipient_id'].inlist(
             getOrgStructureDescendants(filter.orgStructureId)))
     if filter.onlyActive:
         cond.append(table['revoked'].eq(0))
     if filter.begDate:
         cond.append(table['date'].ge(filter.begDate))
     if filter.endDate:
         cond.append(table['date'].le(filter.endDate))
     if filter.begDeadline:
         cond.append(table['deadline'].ge(filter.begDeadline))
     if filter.endDeadline:
         cond.append(table['deadline'].le(filter.endDeadline))
     if filter.nomenclatureId:
         subcond = [
             tableItems['master_id'].eq(table['id']),
             tableItems['nomenclature_id'].eq(filter.nomenclatureId),
         ]
         if filter.onlyActive:
             subcond.append(tableItems['qnt'].ge(
                 tableItems['satisfiedQnt']))
         cond.append(db.existsStmt(tableItems, subcond))
     idList = db.getIdList(table,
                           idCol=table['id'],
                           where=cond,
                           order='date, deadline')
     self.tblRTMs.setIdList(idList, currentId)
     self.lblRTMs.setText(formatRecordsCount(len(idList)))