Hi everyone,
I am hoping to get some advice on how to structure permissions for a custom “Leave Request” DocType. (Note: I cannot use the standard ERPNext Leave Application because our organization requires heavily customized details).
My Current Setup:
-
I have a custom
EmployeeDocType, and each employee is assigned to a specific Department. -
I have a
DepartmentDocType, and each department has a specific Manager assigned to it.
My Permission Requirements:
-
Employees: Need to be able to view their own leave requests. I cannot use the “Only If Creator” checkbox, because sometimes the HR Manager or Department Manager creates the request on their behalf.
-
Department Managers: Need to be able to view all leave requests, but only for the employees within their specific department.
The Constraint: I want to avoid manually managing standard “User Permissions.” If an employee transfers to a new department, or if a manager is replaced, manually updating everyone’s User Permissions will be a nightmare to maintain. I need the system to read the database dynamically.
I have attached a small diagram to clarify the exact list view permissions I need.
Is there a clean way to achieve this dynamic visibility in the Frappe framework? Any guidance on Server Scripts or custom permission queries would be greatly appreciated!
