Skip to content

Commit

Permalink
fix: let administrator approve leaves irrespective of self approval s…
Browse files Browse the repository at this point in the history
…etting
  • Loading branch information
asmitahase committed Dec 6, 2024
1 parent f1b41ea commit 978dafd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions hrms/hr/doctype/leave_application/leave_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,11 +796,13 @@ def create_ledger_entry_for_intermediate_allocation_expiry(self, expiry_date, su

def validate_for_self_approval(self):
self_leave_approval_allowed = frappe.db.get_single_value("HR Settings", "allow_self_leave_approval")

if (not self_leave_approval_allowed) and (
self.employee == get_current_employee_info()["name"]
and not get_workflow_name("Leave Application")
self.employee == get_current_employee_info().get("name")
if get_current_employee_info()
else None and not get_workflow_name("Leave Application")
):
frappe.throw(_("Self approval for leaves is not allowed"), frappe.ValidationError)
frappe.throw(_("Self-approval for leaves is not allowed"), frappe.ValidationError)


def get_allocation_expiry_for_cf_leaves(
Expand Down
2 changes: 2 additions & 0 deletions hrms/hr/doctype/leave_application/test_leave_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,8 @@ def test_self_leave_approval_allowed(self):

self.assertEqual(1, application.docstatus)

frappe.set_user("Administrator")

def test_self_leave_approval_not_allowed(self):
frappe.db.set_single_value("HR Settings", "allow_self_leave_approval", 0)

Expand Down

0 comments on commit 978dafd

Please sign in to comment.