-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Information about bug
Here's the scenario: For three Employees A, B and C in this hierarchy where
- B is the leave approver of A
- C is the leave approver of B
When A applies a leave application via the HR PWA it fetches the leave approver for the leave application form via this whitelisted method
@frappe.whitelist()
def get_leave_approval_details(employee: str) -> dict:
leave_approver, department = frappe.get_cached_value(
"Employee",
employee,
["leave_approver", "department"],
)
if not leave_approver and department:
leave_approver = frappe.db.get_value(
"Department Approver",
{"parent": department, "parentfield": "leave_approvers", "idx": 1},
"approver",
)
leave_approver_name = frappe.db.get_value("User", leave_approver, "full_name", cache=True)
department_approvers = get_department_approvers(department, "leave_approvers")
if leave_approver and leave_approver not in [approver.name for approver in department_approvers]:
department_approvers.append({"name": leave_approver, "full_name": leave_approver_name})
return dict(
leave_approver=leave_approver,
leave_approver_name=leave_approver_name,
department_approvers=department_approvers,
is_mandatory=frappe.db.get_single_value(
"HR Settings", "leave_approver_mandatory_in_leave_application"
),
)
From the frontend it is triggered via this code
const leaveApprovalDetails = createResource({
url: "hrms.api.get_leave_approval_details",
params: { employee: employee.data.name },
onSuccess(data) {
setLeaveApprovers(data)
},
})
This method call from the frontend vue component sends the Employee ID/name whose is currently logged in. This works fine when applying a new leave i.e when A wants to apply for a leave the whitelisted method takes A (who is the currently logged in employee) as param returns the correct approver i.e B
But things go wrong when B (who is the leave approver of A is logged in) and views the leave application in the leave form there again the get_leave_approval_details
is called and this time it sends B as the param because that is the currently logged in employee. Now when B is viewing A's leave application the leave approver field shows: C (because the whitelisted method takes B as input and returns C) as the approver which is obviously INCORRECT because B is the leave approver of A.
In summary the get_leave_approval_details
works fine when a leave application is being applied but when it is being viewed by the approver's end it shows the approvers' approver.
Did anyone else catch this issue?
Module
HR
Version
Frappe - v15.63.1
ERPNext - v15.57.5
Frappe HR - v15.43.0
Installation method
None
Relevant log output / Stack trace / Full Error Message.
Code of Conduct
- I agree to follow this project's Code of Conduct