mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 23:52:57 +00:00
fix: error on group by filter (#24587)
Co-authored-by: Afshan <33727827+AfshanKhan@users.noreply.github.com>
This commit is contained in:
@@ -36,6 +36,8 @@ def execute(filters=None):
|
|||||||
conditions, filters = get_conditions(filters)
|
conditions, filters = get_conditions(filters)
|
||||||
columns, days = get_columns(filters)
|
columns, days = get_columns(filters)
|
||||||
att_map = get_attendance_list(conditions, filters)
|
att_map = get_attendance_list(conditions, filters)
|
||||||
|
if not att_map:
|
||||||
|
return columns, [], None, None
|
||||||
|
|
||||||
if filters.group_by:
|
if filters.group_by:
|
||||||
emp_map, group_by_parameters = get_employee_details(filters.group_by, filters.company)
|
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:
|
if filters.group_by:
|
||||||
emp_att_map = {}
|
emp_att_map = {}
|
||||||
for parameter in group_by_parameters:
|
for parameter in group_by_parameters:
|
||||||
data.append([ "<b>"+ parameter + "</b>"])
|
emp_map_set = set([key for key in emp_map[parameter].keys()])
|
||||||
record, aaa = add_data(emp_map[parameter], att_map, filters, holiday_map, conditions, default_holiday_list, leave_list=leave_list)
|
att_map_set = set([key for key in att_map.keys()])
|
||||||
emp_att_map.update(aaa)
|
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
|
data += record
|
||||||
else:
|
else:
|
||||||
record, emp_att_map = add_data(emp_map, att_map, filters, holiday_map, conditions, default_holiday_list, leave_list=leave_list)
|
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""" %
|
status from tabAttendance where docstatus = 1 %s order by employee, attendance_date""" %
|
||||||
conditions, filters, as_dict=1)
|
conditions, filters, as_dict=1)
|
||||||
|
|
||||||
|
if not attendance_list:
|
||||||
|
msgprint(_("No attendance record found"), alert=True, indicator="orange")
|
||||||
|
|
||||||
att_map = {}
|
att_map = {}
|
||||||
for d in attendance_list:
|
for d in attendance_list:
|
||||||
att_map.setdefault(d.employee, frappe._dict()).setdefault(d.day_of_month, "")
|
att_map.setdefault(d.employee, frappe._dict()).setdefault(d.day_of_month, "")
|
||||||
|
|||||||
Reference in New Issue
Block a user