def __init__(self, parent=None,item=None): GenericTab.__init__(self, parent=parent, item=None) self.ui = Ui_SummaryTab() self.ui.setupUi(self) self.returnItem = False self.visitanimal = None if type(item) is dict: if 'owner' in item: self.ui.ownerNameLabel.setText(item['owner'].name) else: logERROR(self, "SummaryTab.init: owner not found from dict") if 'visitanimal' in item: self.visitanimal = item['visitanimal'] self.ui.animalNameLabel.setText(item['visitanimal'].animal.name) else: logERROR(self, "SummaryTab.init: owner not found from dict") if 'text' in item: self.addText(item['text']) else: logERROR(self, "SummaryTab.init: text not found from dict") else: logDEBUG(self, "SummaryTab.init: item is not dict it is: "+ item) self.session = SqlHandler.newSession() self.itemSearchEdit = SearchLineEdit(tabcreator=AddNewSummary, session=self.session, parent=self, function=SqlHandler.searchSummary) self.configure() self.configureConnctions()
def canCloseTab(self): logDEBUG(self, 'GenericTab FUNCTIO: CanCloseTab') if self.hasChanged(): if self.saveAble(): return self.askUserIfCanClose() else: return True else: return True
def getTotalPrice(self): total = 0.0 for i in range(0, 4): tmp = self.getALVXPrice(i) logDEBUG("tmp", tmp) total += tmp logDEBUG("Total price: ", total) return total
def getTotalPrice(self): total = 0.0 for i in range(0,4): tmp = self.getALVXPrice(i) logDEBUG("tmp", tmp ) total += tmp logDEBUG("Total price: ", total) return total
def getItems(self): tmp = [] if hasattr(self.base, 'item'): logDEBUG(self.base, "has item") tmp.append(self.base.item) if hasattr(self, 'items'): logDEBUG(self, "has items") for i in self.items: #list has surgery items tmp.append(i.item) return tmp
def askUserIfCanClose(self): logDEBUG(self, 'GenericTab FUNCTIO: askUserIfCanClose') reply = QMessageBox.question(self, 'Viesti', self.getMessageBoxText(), QMessageBox.Save, QMessageBox.Cancel, QMessageBox.Discard) if reply == QMessageBox.Save: self.saveTab() return True elif reply == QMessageBox.Discard: return True else: return False
def _addItemToPrice(self, item, price_dict, _count = 1): _type = item.getType() logDEBUG("Operation -> getPriceDict() item type: ", _type) _price = (item.price * _count) if(_type in ['Vaccine', 'Drug','Medicine']): price_dict["medicine_price"] += _price elif(_type in ['Feed']): price_dict["diet_price"] += _price elif(_type in ['Item']): price_dict["accesories_price"] += _price else: logERROR("Operation -> getPriceDict(), base.item has unspesified type: ", _type) return price_dict
def _addItemToPrice(self, item, price_dict, _count=1): _type = item.getType() logDEBUG("Operation -> getPriceDict() item type: ", _type) _price = (item.price * _count) if (_type in ['Vaccine', 'Drug', 'Medicine']): price_dict["medicine_price"] += _price elif (_type in ['Feed']): price_dict["diet_price"] += _price elif (_type in ['Item']): price_dict["accesories_price"] += _price else: logERROR( "Operation -> getPriceDict(), base.item has unspesified type: ", _type) return price_dict
def saveTab(self): logDEBUG(self, 'GenericTab FUNCTIO: SaveTab') #check if tab is valid if self.saveAble(): #check if there is items if self.item == None: #here self.item can be set because newToSaved will handle it self.item = self.makeItem() SqlHandler.addItem(self.session, self.item) self.update() Tabmanager.newToSaved(self) else: self.item.update(self.getData()) SqlHandler.commitSession(self.session) else: from models.translationtables import g_save_error_message self.errorMessage(g_save_error_message)
def saveAndCloseTab(self): logDEBUG(self, 'GenericTab FUNCTIO: saveAndCloseTab') tmp_item = None if self.saveAble(): if self.item == None: self.item = self.makeItem() SqlHandler.addItem(self.session, self.item) else: if self.hasChanged(): #update item if it has changes self.item.update(self.getData()) SqlHandler.commitSession(self.session) else: pass #logDEBUG(self,'No') self.closeTab() else: from models.translationtables import g_save_error_message self.errorMessage(g_save_error_message)
def openItemFromSearch(self): item = self.itemSearchEdit.getCurrentItem() if item : self.openItem(item) else: logDEBUG(self,"openItemFromSearch: item is None");
def closeTab(self): #SLOT logDEBUG(self, 'GenericTab FUNCTIO: closeTab') if self.canCloseTab(): Tabmanager.closeTab(tab=self)
def openItemFromSearch(self): item = self.itemSearchEdit.getCurrentItem() if item: self.openItem(item) else: logDEBUG(self, "openItemFromSearch: item is None")