Fixes throw

This commit is contained in:
Anand Doshi 2014-04-21 11:33:23 +05:30
parent 0900beecb2
commit cbbf451974
6 changed files with 8 additions and 18 deletions

View File

@ -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) stopped = frappe.db.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = %s", d.purchase_order)
if stopped: if stopped:
throw(_("Purchase Order {0} is 'Stopped'").format(d.purchase_order)) throw(_("Purchase Order {0} is 'Stopped'").format(d.purchase_order))
raise Exception
def validate_with_previous_doc(self): def validate_with_previous_doc(self):
super(PurchaseInvoice, self).validate_with_previous_doc(self.tname, { super(PurchaseInvoice, self).validate_with_previous_doc(self.tname, {
@ -168,8 +167,7 @@ class PurchaseInvoice(BuyingController):
if self.is_opening != 'Yes': if self.is_opening != 'Yes':
self.aging_date = self.posting_date self.aging_date = self.posting_date
elif not self.aging_date: elif not self.aging_date:
msgprint(_("Ageing date is mandatory for opening entry")) throw(_("Ageing date is mandatory for opening entry"))
raise Exception
def set_against_expense_account(self): def set_against_expense_account(self):
auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) 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'): for d in self.get('entries'):
if not d.purchase_receipt: if not d.purchase_receipt:
throw(_("Purchase Receipt number required for Item {0}").format(d.item_code)) throw(_("Purchase Receipt number required for Item {0}").format(d.item_code))
raise Exception
def validate_write_off_account(self): def validate_write_off_account(self):
if self.write_off_amount and not self.write_off_account: if self.write_off_amount and not self.write_off_account:

View File

@ -301,9 +301,7 @@ class SalesInvoice(SellingController):
if self.is_opening != 'Yes': if self.is_opening != 'Yes':
self.aging_date = self.posting_date self.aging_date = self.posting_date
elif not self.aging_date: elif not self.aging_date:
msgprint(_("Ageing Date is mandatory for opening entry")) throw(_("Ageing Date is mandatory for opening entry"))
raise Exception
def set_against_income_account(self): def set_against_income_account(self):
"""Set against account for debit to account""" """Set against account for debit to account"""
@ -336,8 +334,7 @@ class SalesInvoice(SellingController):
where name = %s and (customer = %s or where name = %s and (customer = %s or
ifnull(customer,'')='')""", (self.project_name, self.customer)) ifnull(customer,'')='')""", (self.project_name, self.customer))
if not res: if not res:
msgprint(_("Customer {0} does not belong to project {1}").format(self.customer,self.project_name)) throw(_("Customer {0} does not belong to project {1}").format(self.customer,self.project_name))
raise Exception
def validate_pos(self): def validate_pos(self):
if not self.cash_bank_account and flt(self.paid_amount): 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` submitted = frappe.db.sql("""select name from `tabDelivery Note`
where docstatus = 1 and name = %s""", d.delivery_note) where docstatus = 1 and name = %s""", d.delivery_note)
if not submitted: if not submitted:
msgprint(_("Delivery Note {0} is not submitted").format(d.delivery_note)) throw(_("Delivery Note {0} is not submitted").format(d.delivery_note))
raise Exception
def update_stock_ledger(self): def update_stock_ledger(self):
sl_entries = [] sl_entries = []

View File

@ -168,8 +168,7 @@ class PurchaseOrder(BuyingController):
where t1.name = t2.parent and t2.purchase_order = %s and t1.docstatus = 1""", where t1.name = t2.parent and t2.purchase_order = %s and t1.docstatus = 1""",
self.name) self.name)
if submitted: if submitted:
msgprint(_("Purchase Invoice {0} is already submitted").format(", ".join(submitted))) throw(_("Purchase Invoice {0} is already submitted").format(", ".join(submitted)))
raise Exception
frappe.db.set(self,'status','Cancelled') frappe.db.set(self,'status','Cancelled')
self.update_prevdoc_status() self.update_prevdoc_status()

View File

@ -71,8 +71,8 @@ class LeaveApplication(DocListController):
if block_dates: if block_dates:
if self.status == "Approved": if self.status == "Approved":
frappe.msgprint(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates")) frappe.throw(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates"),
raise LeaveDayBlockedError LeaveDayBlockedError)
def get_holidays(self): def get_holidays(self):
tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1 tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1

View File

@ -49,8 +49,7 @@ class Opportunity(TransactionBase):
return ret return ret
else: else:
msgprint("Customer : %s does not exist in system." % (name)) frappe.throw(_("Customer {0} does not exist").format(name), frappe.DoesNotExistError)
raise Exception
def on_update(self): def on_update(self):
self.add_calendar_event() self.add_calendar_event()

View File

@ -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']]): 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.msgprint(_("Not authroized since {0} exceeds limits").format(_(based_on)))
frappe.throw(_("Can be approved by {0}").format(comma_or(appr_roles + appr_users))) 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 # Check if authorization rule is set specific to user