Пример #1
0
 def _load(self):
     self._unit = CRbItemInfo(context=self.context,
                              item=CPharmacyService.getInstance().getItem(
                                  MeasurementUnit, self._item.unit))
     self._catalog = CCatalogInfo(
         context=self.context,
         item=CPharmacyService.getInstance().getItem(
             Catalog, self._item.catalog))
     return True
Пример #2
0
 def _getItems(self):
     if self._items is None:
         try:
             if self._storeId:
                 items = CPharmacyService.getInstance().getFlatStoreItems(storeId=self._storeId, detailed=True)
                 items = [item.item for item in items]
             else:
                 items = CPharmacyService.getInstance().getStoreItems()
         except CPharmacyServiceException:
             items = []
         if self._order:
             items = sorted(items, key=lambda item: getattr(item, self._order, u'').lower())
         self._items = items
     return self._items
Пример #3
0
 def testConnect(self):
     settings = self.getSettings()
     srv = CPharmacyService(settings['URL'], settings['User'],
                            settings['Password'])
     currentUser, error = srv.testConnect()
     if currentUser and currentUser.id is not None:
         QtGui.QMessageBox.information(
             self, u'Проверка соединения',
             u'Соединение успешно<br>Текущий пользователь: <b>{0} | {1}</b>'
             .format(currentUser.username,
                     currentUser.fullName), QtGui.QMessageBox.Ok)
     else:
         QtGui.QMessageBox.warning(
             self, u'Проверка соединения',
             u'Соединение не удалось:<br>{0}'.format(error),
             QtGui.QMessageBox.Ok)
Пример #4
0
    def __init__(self, parent):
        super(CM11DocumentDialog, self).__init__(parent)
        self.addModels('RequestDocumentItems', CRequestDocumentItems(self))
        self.addModels('M11DocumentItems', CM11DocumentItems(self))

        self.setupUi(self)
        self.setWindowTitle(u'Отработка требования')

        self.setModels(self.tblRequestDocumentItems,
                       self.modelRequestDocumentItems,
                       self.selectionModelRequestDocumentItems)
        self.setModels(self.tblM11DocumentItems, self.modelM11DocumentItems,
                       self.selectionModelM11DocumentItems)

        self._editable = False
        self._doc = M11Document()
        self._requestDoc = RequestDocument()
        self._srv = CPharmacyService.getInstance()

        self.edtDatetime.setDate(QtCore.QDate.currentDate())
        self.cmbStoreFrom.setItems(self._srv.getStores())
        self.cmbUser.setItems(self._srv.getFlatUserList())

        self.btnSelectItems.clicked.connect(self.selectStoreItems)
        self.btnFinalize.clicked.connect(self.saveDocument)
Пример #5
0
    def __init__(self, parent):
        CDialogBase.__init__(self, parent)
        self._doc = InventoryDocument()
        self._srv = CPharmacyService.getInstance()
        self._editable = False
        self.addModels('Items', CInventoryItemsModel(self))
        self._proxyModel = CItemListSortFilterProxyModel(self)
        self._proxyModel.setSourceModel(self.modelItems)

        self.setupUi(self)
        self.setWindowTitle(u'Инвентаризация')

        self.edtDatetime.setDateTime(QtCore.QDateTime.currentDateTime())
        self.cmbUser.setItems(self._srv.getFlatUserList())
        self.cmbStore.setItems(self._srv.getStores())
        self.cmbCatalog.setItems(self._srv.getCatalogs(), addNone=True)

        self.cmbStore.currentIndexChanged.connect(self.reloadStoreItems)
        self.cmbCatalog.currentIndexChanged.connect(self.reloadStoreItems)

        self.setModels(self.tblItems, self._proxyModel,
                       self.selectionModelItems)
        self.tblItems.setItemDelegate(CLocItemProxyDelegate(self.tblItems))

        self.edtSearch.textChanged.connect(self.updateFilter)
        self.btnResetSearch.clicked.connect(self.resetFilter)
        self.btnSaveInventory.clicked.connect(self.saveData)
        self.installEventFilter(self)
Пример #6
0
 def _load(self):
     srv = CPharmacyService.getInstance()
     self._unit = CRbItemInfo(self.context,
                              item=srv.getItem(MeasurementUnit,
                                               self._item.unit))
     self._store = CStoreInfo(self.context,
                              item=srv.getItem(Store, self._item.store))
     self._itemClass = ExpirationClass.getDateClassName(
         self._item.expiryDate)
     return True
Пример #7
0
    def _initService(self):
        url = self._settings.get('URL')
        user = self._settings.get('User')
        password = self._settings.get('Password')
        if not (url and user and password):
            QtGui.QMessageBox.information(
                self, self.windowTitle(),
                u'Не заданы параметры подключения к серверу',
                QtGui.QMessageBox.Ok)
            return

        srv = CPharmacyService(url, user, password)
        currentUser, error = srv.testConnect()
        if not (currentUser and currentUser.id):
            QtGui.QMessageBox.information(
                self, u'Не удалось подключиться к серверу', unicode(error),
                QtGui.QMessageBox.Ok)
            return

        self._srv = srv
        if self._initCache():
            self.tabWidget.setEnabled(True)
            for tabName, tab, isVisible in (
                (u'Просмотр остатков', self.tabStoreItem,
                 True), (u'Накладные', self.tabShippingDocument,
                         currentUser.hasAnyPermission(
                             (UserPermission.EditShipping,
                              UserPermission.FinalizeShipping))),
                (u'Требования', self.tabRequestDocument,
                 currentUser.hasAnyPermission(
                     (UserPermission.EditRequest,
                      UserPermission.FinalizeRequest, UserPermission.EditM11,
                      UserPermission.FinalizeM11))),
                (u'Инвентаризация', self.tabInventoryDocument,
                 currentUser.hasAnyPermission(
                     (UserPermission.EditM11, UserPermission.FinalizeM11)))):
                if isVisible:
                    self.tabWidget.addTab(tab, tabName)
            self.tabWidget.setCurrentIndex(0)

            self.actConnect.setVisible(False)
            self.actDisconnect.setVisible(True)
Пример #8
0
    def _deinitService(self):
        self._srv = None
        CPharmacyService.reset()

        self.clearStoreItemsFilter()
        self.clearShippingDocumentFilter()
        self.clearRequestDocumentFilter()
        self.clearInventoryDocumentFilter()
        self.tblStoreItems.model().clearItems()
        self.tblShippingDocuments.model().clearItems()
        self.tblIncomingRequestDocuments.model().clearItems()
        self.tblOutcomingRequestDocuments.model().clearItems()
        self.tblInventoryDocuments.model().clearItems()

        self.tabWidget.setCurrentIndex(0)
        for tabIdx in range(self.tabWidget.count()):
            self.tabWidget.removeTab(0)
        self.tabWidget.setEnabled(False)
        self.actConnect.setVisible(True)
        self.actDisconnect.setVisible(False)
Пример #9
0
    def __init__(self, parent):
        CDialogBase.__init__(self, parent)
        self._srv = CPharmacyService.getInstance()

        self.addModels('ShippingInfo', CCatalogItemShippingInfoModel(self))

        self.setupUi(self)
        self.setWindowTitle(u'Информация о товаре')

        self.setModels(self.tblShippingInfo, self.modelShippingInfo,
                       self.selectionModelShippingInfo)
        self.tblShippingInfo.doubleClicked.connect(self.openShippingDocument)
        self._item = None
Пример #10
0
 def displayValue(self, item, **params):
     u"""
     :type item: RequestDocument
     :param params: 
     """
     if item.transferFinished:
         for m11DocumentId in item.m11List:
             try:
                 doc = CPharmacyService.getInstance().getItem(M11Document, m11DocumentId)  # type: M11Document
             except CPharmacyServiceException:
                 doc = None
             if doc and doc.finalizeDate:
                 return doc.finalizeDate
     return None
Пример #11
0
    def _load(self):
        if not self._doc:
            try:
                self._doc = CPharmacyService.getInstance().getItem(
                    RequestDocument, self._itemId)
            except Exception:
                self._doc = RequestDocument()

        self._datetime = CDateTimeInfo(self._doc.date)
        self._date = CDateInfo(self._doc.date.date())
        self._finalizeDate = CDateInfo(self._doc.finalizeDate.date())
        self._type = RequestDocumentType.getName(self._doc.type)
        self._storeFrom = CStoreInfo(self.context, itemId=self._doc.storeTo)
        self._storeTo = CStoreInfo(self.context, itemId=self._doc.storeFrom)
        self._positions = [
            CDocumentPositionInfo(self.context, position)
            for position in self._positions
        ]
Пример #12
0
    def __init__(self, parent):
        super(CRequestDocumentDialog, self).__init__(parent)

        self.addModels('Items', CRequestDocumentItemsModel(self))

        self.setupUi(self)
        self.setWindowTitle(u'Требование')

        self.setModels(self.tblItems, self.modelItems, self.selectionModelItems)

        self._doc = RequestDocument()
        self._srv = CPharmacyService.getInstance()
        self._finalizeEnabled = self._srv.getCurrentUser().hasPermission(UserPermission.FinalizeRequest)
        self._numberCounter = getCounter(self.NumberCounterCode)

        self.edtNumber.setText(unicode(getCounterValue(counterId=self._numberCounter) or u''))
        self.cmbType.setEnum(RequestDocumentType)
        self.edtDatetime.setDateTime(QtCore.QDateTime.currentDateTime())
        self.cmbUser.setItems(self._srv.getFlatUserList())
        self.cmbStoreFrom.setItems(self._srv.getStores())
        self.cmbStoreTo.setItems(self._srv.getStores())

        self.btnFinalize.clicked.connect(self.saveDocument)
Пример #13
0
 def displayValue(self, item, **params):
     itemId = super(CRbItemRefAttribCol, self).displayValue(item, **params)
     item = CPharmacyService.getInstance().getItem(self._itemType, itemId)
     return item.codeName if item else None
Пример #14
0
 def close(self):
     CPharmacyService.reset()
     super(CPharmacyStoreDialog, self).close()
Пример #15
0
 def setStore(self, storeId):
     self._storeId = storeId
     self._storeItemAmountMap = CPharmacyService.getInstance().getStoreItemAmountMap(storeId)
     self._storeItemCol.setStore(storeId)
Пример #16
0
 def displayValue(self, item, **params):
     itemId = super(CStoreItemCol, self).displayValue(item, **params)
     storeItem = CPharmacyService.getInstance().getItem(StoreItem, itemId)
     return storeItem.tradeName
Пример #17
0
 def _load(self):
     if not self._item:
         self._item = CPharmacyService.getInstance().getItem(
             Store, self._itemId)
Пример #18
0
 def __init__(self, parent, storeId, catalogId=None):
     super(CStoreStockReport, self).__init__(parent)
     self.setTitle(u'Отчет за период')
     self.storeId = storeId
     self.catalogId = catalogId
     self.srv = CPharmacyService.getInstance()
Пример #19
0
 def displayValue(self, item, **params):
     itemId = super(CReferenceAttribCol, self).displayValue(item, **params)
     refItem = CPharmacyService.getInstance().getItem(
         self._itemType, itemId)
     return getattr(refItem, self._refAttribName, self._default)