-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: toggle self leave approval for employees from HR settings #2486
base: develop
Are you sure you want to change the base?
Conversation
… based on the leave approval HR setting
978dafd
to
c831870
Compare
"default": "1", | ||
"fieldname": "allow_self_leave_approval", | ||
"fieldtype": "Check", | ||
"label": "Enable Self-Approval For Leaves" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"label": "Enable Self-Approval For Leaves" | |
"label": "Allow self approval for Leave Application" |
Fieldname says allow so keep it consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this setting, Approval field should also become read-only - client-side change
|
||
if (not self_leave_approval_allowed) and ( | ||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (not self_leave_approval_allowed) and ( | |
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) | |
employee_user = frappe.db.get_value("Employee", self.employee, "user_id") | |
if ( | |
employee_user == frappe.session.user | |
and not self_leave_approval_allowed | |
and not get_workflow_name("Leave Application") | |
): | |
frappe.throw(_("Self approval for leaves is not allowed")) |
Issue
Immediately after employees create and save leave application they see the document with "submit" as primary action that can lead to confusion as to clicking submit is part of the leave application process. So the employees ended up submitting their own leaves even if a different leave approver was already set in the application.
Role permission do not help in case one employee is leave approver for another employee.
Before
self_leave_approval_before.mov
After
self_leave_approval_pwa_after.mov
Screen.Recording.2024-12-06.at.12.48.36.PM.mov
Fix
Added a new setting in HR Settings called Enable Self-Approval for Leaves which is enabled by default.
The submit action is removed on leave application if self approval is not enabled. Self approval setting is ignored if the leave application doctype has a workflow.
Added tests for when self approval is enabled/disabled
I'll update the documentation once this is merged, no-docs for now