def __init__(self, name, address, phone, fax="", email="", web="", logo_filename=None): # The first three parameters are required. The configuration management # should have already confirmed that they are fine. if name is None: raise ValueError("The name parameter is invalid.") if address is None: raise ValueError("The address parameter is invalid.") if phone is None: raise ValueError("The phone parameter is invalid.") if logo_filename is None or logo_filename == "": # No logo filename. No problem. self.logo_filename = None else: if os.path.exists(logo_filename) != True: self.logo_filename = None execute_warning_msg_box(DATA_VAL_ERROR_MSG_BOX_TITLE, ("The configured company logo file " "could not be found. The PDF will " "be generated without it."), QMessageBox.Ok) else: self.logo_filename = logo_filename self.name = name self.address_lines = validate_num_address_lines(address) self.address = address self.phone = phone self.fax = fax self.email = email self.web = web
def warn_about_changing_used_data(item_name): '''Warn the user about changing data that is referenced in a purchase order. Shows a message box describing the consequences of changing data that is referenced in a purchase order, and asks the user to confirm that she wants to do this. Args: :param item_name: The top-level data item that is being changed, e.g., "project", "supplier", "product". :type item_name: String Returns: :return: The message box result, which is either "Yes" or "Cancel". :rtype: QMessageBox.Yes or QMessageBox.Cancel ''' result = execute_warning_msg_box( "Data Warning", ("You are changing the data of a {} that has been used in " "one or more purchase orders. If you do this then those " "purchase orders will reflect the new data. The old data " "will be lost.\n\nAre you sure you want to change this " "{}'s data?").format(item_name, item_name), QMessageBox.Yes | QMessageBox.Cancel) return result
def show_save_before_close(self): if self.active_po_model and self.active_po_model.dirty: result = execute_warning_msg_box( self.MSG_BOX_TITLE_UNSAVED_CHANGES, ("There are some unsaved changes. These must be " "either saved or discarded before closing the " "application."), QMessageBox.Save | QMessageBox.Discard) if result == QMessageBox.Save: self.save_all() else: self.session.rollback() self.active_po_model.do_post_rollback_processing()
def on_supplierComboBox_currentIndexChanged(self, text): if self.active_po_model: if self.active_po_model.has_line_items() is True: result = execute_warning_msg_box( "Supplier Change Warning", ("You are trying to change the supplier of a " "purchase order with items on it."), QMessageBox.Ok | QMessageBox.Cancel, info_text=("If you do this then all of the " "current line items on this " "purchase order will be removed. " "Click OK to continue.")) if result == QMessageBox.Ok: self.active_po_model.set_supplier(self.session, text) else: return else: self.active_po_model.set_supplier(self.session, text) self.update_supplier_info() self.initialise_product_table()