[minor] user properties and leave application

This commit is contained in:
Anand Doshi
2013-12-13 11:51:50 +05:30
parent 83638b5f05
commit bcf2422848
7 changed files with 67 additions and 52 deletions

View File

@@ -12,6 +12,7 @@ from webnotes import msgprint
class LeaveDayBlockedError(webnotes.ValidationError): pass
class OverlapError(webnotes.ValidationError): pass
class InvalidLeaveApproverError(webnotes.ValidationError): pass
class LeaveApproverIdentityError(webnotes.ValidationError): pass
from webnotes.model.controller import DocListController
class DocType(DocListController):
@@ -161,6 +162,10 @@ class DocType(DocListController):
where parent=%s and role='Leave Approver'""", self.doc.leave_approver):
msgprint(get_fullname(self.doc.leave_approver) + ": " \
+ _("does not have role 'Leave Approver'"), raise_exception=InvalidLeaveApproverError)
elif self.doc.docstatus==1 and len(leave_approvers) and self.doc.leave_approver != webnotes.session.user:
msgprint(_("Only the selected Leave Approver can submit this Leave Application"),
raise_exception=LeaveApproverIdentityError)
def notify_employee(self, status):
employee = webnotes.doc("Employee", self.doc.employee)

View File

@@ -163,8 +163,8 @@ class TestLeaveApplication(unittest.TestCase):
webnotes.set_user("test1@example.com")
application.doc.status = "Approved"
from webnotes.model.bean import BeanPermissionError
self.assertRaises(BeanPermissionError, application.submit)
from hr.doctype.leave_application.leave_application import LeaveApproverIdentityError
self.assertRaises(LeaveApproverIdentityError, application.submit)
webnotes.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
"_T-Employee-0001")