From 00e57e13b695a6daa67a98b184b9a41cc84d49b4 Mon Sep 17 00:00:00 2001 From: krantheman Date: Fri, 13 Sep 2024 11:32:57 +0530 Subject: [PATCH 1/2] fix(Monthly Attendance Sheet): consideration of None values while grouping (cherry picked from commit 5e45e2b982193fd82f8ab864f7f0895f22ea14c8) --- .../report/monthly_attendance_sheet/monthly_attendance_sheet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py b/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py index e74bac6a82..6bdf03f11f 100644 --- a/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py +++ b/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py @@ -305,7 +305,7 @@ def get_employee_related_details(filters: Filters) -> tuple[dict, list]: emp_map = {} if group_by: - group_key = lambda d: d[group_by] # noqa + group_key = lambda d: "" if d[group_by] is None else d[group_by] # noqa for parameter, employees in groupby(sorted(employee_details, key=group_key), key=group_key): group_by_param_values.append(parameter) emp_map.setdefault(parameter, frappe._dict()) From 0e22d200074bca8b9aed270ff0fb410f0b43b897 Mon Sep 17 00:00:00 2001 From: krantheman Date: Fri, 13 Sep 2024 11:49:42 +0530 Subject: [PATCH 2/2] test: consider None values while testing group by filter (cherry picked from commit 4d9bcfb57654e6d9dbd383625abf49aed6127a80) --- .../test_monthly_attendance_sheet.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hrms/hr/report/monthly_attendance_sheet/test_monthly_attendance_sheet.py b/hrms/hr/report/monthly_attendance_sheet/test_monthly_attendance_sheet.py index 71fa9745e1..2fdc24a07d 100644 --- a/hrms/hr/report/monthly_attendance_sheet/test_monthly_attendance_sheet.py +++ b/hrms/hr/report/monthly_attendance_sheet/test_monthly_attendance_sheet.py @@ -205,6 +205,11 @@ def test_attendance_with_group_by_filter(self): mark_attendance(self.employee, previous_month_first + relativedelta(days=2), "On Leave") mark_attendance(self.employee, previous_month_first + relativedelta(days=3), "Present") + departmentless_employee = make_employee( + "emp@departmentless.com", company=self.company, department=None + ) + mark_attendance(departmentless_employee, previous_month_first + relativedelta(days=3), "Present") + filters = frappe._dict( { "month": previous_month_first.month,