mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
[minor] user properties and leave application
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user