Merge pull request #7565 from KanchanChauhan/leave-balance-report-fix
[Fix] Permissions to view Leave Balance Report
This commit is contained in:
commit
2dfb90a922
@ -30,15 +30,18 @@ def get_columns(leave_types):
|
||||
return columns
|
||||
|
||||
def get_data(filters, leave_types):
|
||||
|
||||
user = frappe.session.user
|
||||
allocation_records_based_on_to_date = get_leave_allocation_records(filters.to_date)
|
||||
|
||||
active_employees = frappe.get_all("Employee",
|
||||
filters = { "status": "Active", "company": filters.company},
|
||||
fields = ["name", "employee_name", "department"])
|
||||
fields = ["name", "employee_name", "department", "user_id"])
|
||||
|
||||
data = []
|
||||
for employee in active_employees:
|
||||
leave_approvers = [l.leave_approver for l in frappe.db.sql("""select leave_approver from `tabEmployee Leave Approver` where parent = %s""",
|
||||
(employee.name),as_dict=True)]
|
||||
if (len(leave_approvers) and user in leave_approvers) or (user in ["Administrator", employee.user_id]) or ("HR Manager" in frappe.get_roles(user)):
|
||||
row = [employee.name, employee.employee_name, employee.department]
|
||||
|
||||
for leave_type in leave_types:
|
||||
|
Loading…
Reference in New Issue
Block a user