show leave application of other employees in deparment if user has Employee role, but also show leave applications based on permissions - show unique of both
diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py
index 8117718..313f27f 100755
--- a/hr/doctype/leave_application/leave_application.py
+++ b/hr/doctype/leave_application/leave_application.py
@@ -236,14 +236,11 @@
match_conditions = build_match_conditions("Leave Application")
# show department leaves for employee
- show_department_leaves = match_conditions and \
- len(match_conditions.split("or"))==1 and "employee" in match_conditions
-
- if show_department_leaves:
+ if "Employee" in webnotes.get_roles():
add_department_leaves(events, start, end, employee, company)
- else:
- add_leaves(events, start, end, employee, company, match_conditions)
-
+
+ add_leaves(events, start, end, employee, company, match_conditions)
+
add_block_dates(events, start, end, employee, company)
add_holidays(events, start, end, employee, company)
@@ -273,7 +270,7 @@
query += " and " + match_conditions
for d in webnotes.conn.sql(query, (start, end, start, end), as_dict=True):
- events.append({
+ e = {
"name": d.name,
"doctype": "Leave Application",
"from_date": d.from_date,
@@ -282,7 +279,9 @@
"title": _("Leave by") + " " + cstr(d.employee_name) + \
(d.half_day and _(" (Half Day)") or ""),
"docstatus": d.docstatus
- })
+ }
+ if e not in events:
+ events.append(e)
def add_block_dates(events, start, end, employee, company):
# block days