fix: error on group by filter (#24587)
Co-authored-by: Afshan <33727827+AfshanKhan@users.noreply.github.com>
This commit is contained in:
parent
1016ff48fc
commit
5164223b99
@ -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,10 +67,14 @@ 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)
|
||||
data += record
|
||||
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)
|
||||
data += record
|
||||
@ -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, "")
|
||||
|
Loading…
x
Reference in New Issue
Block a user