diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 21b088566a..80aa73a197 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -123,7 +123,6 @@ class PurchaseInvoice(BuyingController): stopped = frappe.db.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = %s", d.purchase_order) if stopped: throw(_("Purchase Order {0} is 'Stopped'").format(d.purchase_order)) - raise Exception def validate_with_previous_doc(self): super(PurchaseInvoice, self).validate_with_previous_doc(self.tname, { @@ -168,8 +167,7 @@ class PurchaseInvoice(BuyingController): if self.is_opening != 'Yes': self.aging_date = self.posting_date elif not self.aging_date: - msgprint(_("Ageing date is mandatory for opening entry")) - raise Exception + throw(_("Ageing date is mandatory for opening entry")) def set_against_expense_account(self): auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) @@ -210,7 +208,6 @@ class PurchaseInvoice(BuyingController): for d in self.get('entries'): if not d.purchase_receipt: throw(_("Purchase Receipt number required for Item {0}").format(d.item_code)) - raise Exception def validate_write_off_account(self): if self.write_off_amount and not self.write_off_account: diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index b5bf73f8ff..b40722c116 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -301,9 +301,7 @@ class SalesInvoice(SellingController): if self.is_opening != 'Yes': self.aging_date = self.posting_date elif not self.aging_date: - msgprint(_("Ageing Date is mandatory for opening entry")) - raise Exception - + throw(_("Ageing Date is mandatory for opening entry")) def set_against_income_account(self): """Set against account for debit to account""" @@ -336,8 +334,7 @@ class SalesInvoice(SellingController): where name = %s and (customer = %s or ifnull(customer,'')='')""", (self.project_name, self.customer)) if not res: - msgprint(_("Customer {0} does not belong to project {1}").format(self.customer,self.project_name)) - raise Exception + throw(_("Customer {0} does not belong to project {1}").format(self.customer,self.project_name)) def validate_pos(self): if not self.cash_bank_account and flt(self.paid_amount): @@ -440,8 +437,7 @@ class SalesInvoice(SellingController): submitted = frappe.db.sql("""select name from `tabDelivery Note` where docstatus = 1 and name = %s""", d.delivery_note) if not submitted: - msgprint(_("Delivery Note {0} is not submitted").format(d.delivery_note)) - raise Exception + throw(_("Delivery Note {0} is not submitted").format(d.delivery_note)) def update_stock_ledger(self): sl_entries = [] diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index 02170ff464..a83debcce7 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -168,8 +168,7 @@ class PurchaseOrder(BuyingController): where t1.name = t2.parent and t2.purchase_order = %s and t1.docstatus = 1""", self.name) if submitted: - msgprint(_("Purchase Invoice {0} is already submitted").format(", ".join(submitted))) - raise Exception + throw(_("Purchase Invoice {0} is already submitted").format(", ".join(submitted))) frappe.db.set(self,'status','Cancelled') self.update_prevdoc_status() diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index f7084eff60..d74e930feb 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -71,8 +71,8 @@ class LeaveApplication(DocListController): if block_dates: if self.status == "Approved": - frappe.msgprint(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates")) - raise LeaveDayBlockedError + frappe.throw(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates"), + LeaveDayBlockedError) def get_holidays(self): tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1 diff --git a/erpnext/selling/doctype/opportunity/opportunity.py b/erpnext/selling/doctype/opportunity/opportunity.py index 9ba6e56382..41b42ead18 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.py +++ b/erpnext/selling/doctype/opportunity/opportunity.py @@ -49,8 +49,7 @@ class Opportunity(TransactionBase): return ret else: - msgprint("Customer : %s does not exist in system." % (name)) - raise Exception + frappe.throw(_("Customer {0} does not exist").format(name), frappe.DoesNotExistError) def on_update(self): self.add_calendar_event() diff --git a/erpnext/setup/doctype/authorization_control/authorization_control.py b/erpnext/setup/doctype/authorization_control/authorization_control.py index 25d2de0708..03c187b15b 100644 --- a/erpnext/setup/doctype/authorization_control/authorization_control.py +++ b/erpnext/setup/doctype/authorization_control/authorization_control.py @@ -35,7 +35,6 @@ class AuthorizationControl(TransactionBase): if not has_common(appr_roles, frappe.user.get_roles()) and not has_common(appr_users, [session['user']]): frappe.msgprint(_("Not authroized since {0} exceeds limits").format(_(based_on))) frappe.throw(_("Can be approved by {0}").format(comma_or(appr_roles + appr_users))) - raise Exception # Check if authorization rule is set specific to user