From 89e70d77cae61c62e454a94de498986fa98ce074 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 27 Feb 2013 18:46:21 +0530 Subject: [PATCH] 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 --- .../leave_application/leave_application.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py index 81177180f6..313f27f8ec 100755 --- a/hr/doctype/leave_application/leave_application.py +++ b/hr/doctype/leave_application/leave_application.py @@ -236,14 +236,11 @@ def get_events(start, end): 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 @@ def add_leaves(events, start, end, employee, company, match_conditions=None): 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 @@ def add_leaves(events, start, end, employee, company, match_conditions=None): "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