Problem with Leave approval permission

Hello everyone,

I have the following problem:

I created a workflow for leave approvals that works like this: First, the leave must be approved by the leave approver assigned to each employee, then it goes to the Dashboard Manager, and finally to HR. In my case, the Dashboard Manager has access to all employees, and he is also the leave approver for some employees. So, I gave him permission as a leave approver.

Now, when an employee from the technical section, for example, applies for leave, the Dashboard Manager can approve it as a leave approver (even though he is not the assigned approver for that employee) and also as the Dashboard Manager.

How can I resolve this issue?

Add the following code in the Leave Approval workflow Transaction.

frappe.session.user == frappe.db.get_value("Employee", {"leave_approver": frappe.session.user}, 'leave_approver')

Edit after Problem with Leave approval permission - #3 by Alexis_Dali this response :sweat_smile:

frappe.session.user == frappe.db.get_value(“Employee”, {“name”: doc.employee}, “leave_approver”)
1 Like

Thank very much my friend @ejaaz for your interest and assist.
I just edit your code to this frappe.session.user == frappe.db.get_value(“Employee”, {“name”: doc.employee}, “leave_approver”)
and that’s solve my problem.

1 Like