From f31221d0d33cf186e7a7015ccb7de9ae66947067 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 9 Jul 2014 09:13:00 +0530 Subject: [PATCH] Changed `raise Exception` to `frappe.throw` --- .../accounts/doctype/sales_invoice/sales_invoice.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 834865bcd6..5e29487b50 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -339,8 +339,8 @@ class SalesInvoice(SellingController): def validate_pos(self): if not self.cash_bank_account and flt(self.paid_amount): - msgprint(_("Cash or Bank Account is mandatory for making payment entry")) - raise Exception + frappe.throw(_("Cash or Bank Account is mandatory for making payment entry")) + if flt(self.paid_amount) + flt(self.write_off_amount) \ - flt(self.grand_total) > 1/(10**(self.precision("grand_total") + 1)): frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total""")) @@ -431,9 +431,8 @@ class SalesInvoice(SellingController): submitted = frappe.db.sql("""select name from `tabSales Order` where docstatus = 1 and name = %s""", d.sales_order) if not submitted: - msgprint(_("Sales Order {0} is not submitted").format(d.sales_order)) - raise Exception - + frappe.throw(_("Sales Order {0} is not submitted").format(d.sales_order)) + if d.delivery_note: submitted = frappe.db.sql("""select name from `tabDelivery Note` where docstatus = 1 and name = %s""", d.delivery_note) @@ -682,7 +681,7 @@ def manage_recurring_invoices(next_date=None, commit=True): if exception_list: exception_message = "\n\n".join([cstr(d) for d in exception_list]) - raise Exception, exception_message + frappe.throw(exception_message) def make_new_invoice(ref_wrapper, posting_date): from erpnext.accounts.utils import get_fiscal_year