fix: error on group by filter (#24587)

Co-authored-by: Afshan <33727827+AfshanKhan@users.noreply.github.com>
This commit is contained in:
Anurag Mishra 2021-02-09 16:22:28 +05:30 committed by GitHub
parent 1016ff48fc
commit 5164223b99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,6 +36,8 @@ def execute(filters=None):
conditions, filters = get_conditions(filters)
columns, days = get_columns(filters)
att_map = get_attendance_list(conditions, filters)
if not att_map:
return columns, [], None, None
if filters.group_by:
emp_map, group_by_parameters = get_employee_details(filters.group_by, filters.company)
@ -65,9 +67,13 @@ def execute(filters=None):
if filters.group_by:
emp_att_map = {}
for parameter in group_by_parameters:
data.append([ "<b>"+ parameter + "</b>"])
record, aaa = add_data(emp_map[parameter], att_map, filters, holiday_map, conditions, default_holiday_list, leave_list=leave_list)
emp_att_map.update(aaa)
emp_map_set = set([key for key in emp_map[parameter].keys()])
att_map_set = set([key for key in att_map.keys()])
if (att_map_set & emp_map_set):
parameter_row = ["<b>"+ parameter + "</b>"] + ['' for day in range(filters["total_days_in_month"] + 2)]
data.append(parameter_row)
record, emp_att_data = add_data(emp_map[parameter], att_map, filters, holiday_map, conditions, default_holiday_list, leave_list=leave_list)
emp_att_map.update(emp_att_data)
data += record
else:
record, emp_att_map = add_data(emp_map, att_map, filters, holiday_map, conditions, default_holiday_list, leave_list=leave_list)
@ -237,6 +243,9 @@ def get_attendance_list(conditions, filters):
status from tabAttendance where docstatus = 1 %s order by employee, attendance_date""" %
conditions, filters, as_dict=1)
if not attendance_list:
msgprint(_("No attendance record found"), alert=True, indicator="orange")
att_map = {}
for d in attendance_list:
att_map.setdefault(d.employee, frappe._dict()).setdefault(d.day_of_month, "")