From c09128ab47f7b232d095e251af3ec34a86a835b8 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 5 Dec 2012 17:27:48 +0530 Subject: [PATCH] message updates in Leave / Expense, catch localstorage error --- hr/doctype/expense_claim/expense_claim.py | 15 +++++++++------ hr/doctype/leave_application/leave_application.py | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hr/doctype/expense_claim/expense_claim.py b/hr/doctype/expense_claim/expense_claim.py index 2495fb4c21..b5fddda14f 100644 --- a/hr/doctype/expense_claim/expense_claim.py +++ b/hr/doctype/expense_claim/expense_claim.py @@ -27,10 +27,16 @@ class DocType: def __init__(self, doc, doclist=[]): self.doc = doc self.doclist = doclist - + + def validate(self): + if self.doc.exp_approver == self.doc.owner: + webnotes.msgprint("""Self Approval is not allowed.""", raise_exception=1) + self.validate_fiscal_year() + self.validate_exp_details() + def on_submit(self): - if self.doc.status=="Draft": - webnotes.msgprint("""Please set status to 'Approved' or 'Rejected' before submitting""", + if self.doc.approval_status=="Draft": + webnotes.msgprint("""Please set Approval Status to 'Approved' or 'Rejected' before submitting""", raise_exception=1) def validate_fiscal_year(self): @@ -40,9 +46,6 @@ class DocType: if str(self.doc.posting_date) < str(ysd) or str(self.doc.posting_date) > str(yed): msgprint("Posting Date is not within the Fiscal Year selected") raise Exception - - def validate(self): - self.validate_fiscal_year() def validate_exp_details(self): if not getlist(self.doclist, 'expense_voucher_details'): diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py index 1cf23ac45a..bd76c7df45 100755 --- a/hr/doctype/leave_application/leave_application.py +++ b/hr/doctype/leave_application/leave_application.py @@ -90,6 +90,9 @@ class DocType: raise Exception def validate(self): + if self.doc.leave_approver == self.doc.owner: + webnotes.msgprint("""Self Approval is not allowed.""", raise_exception=1) + self.validate_to_date() self.validate_balance_leaves() self.validate_leave_overlap()