From 5993413a0fdc146f5d38ebabfdd44ad1ad871324 Mon Sep 17 00:00:00 2001 From: Samir Ladoui Date: Mon, 4 Aug 2025 14:32:19 +0100 Subject: [PATCH] [FIX] attendances --- .../wizard/attendances_report_wiz.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/odex25_hr/attendances/wizard/attendances_report_wiz.py b/odex25_hr/attendances/wizard/attendances_report_wiz.py index bc84b895a..e9f0805ee 100644 --- a/odex25_hr/attendances/wizard/attendances_report_wiz.py +++ b/odex25_hr/attendances/wizard/attendances_report_wiz.py @@ -247,6 +247,7 @@ class ReportAttendancePublic(models.AbstractModel): start_date = data['form']['from_date'] end_date = data['form']['to_date'] type_ = data['form']['type'] + shift_mode = data['form']['shift_mode'] totals_only = data['form'].get('print_totals_only', False) summary_rows = [] @@ -262,6 +263,11 @@ class ReportAttendancePublic(models.AbstractModel): domain.append(('employee_id', 'in', rc.employee_ids.ids)) att = self.env['hr.attendance.transaction'].search(domain) + if shift_mode != 'both': + if shift_mode == 'first': + att = att.filtered(lambda r: r.sequence == 1) + elif shift_mode == 'second': + att = att.filtered(lambda r: r.sequence == 2) for emp in att.mapped('employee_id'): # lines = att.filtered(lambda l, e=emp: l.employee_id == e) @@ -348,6 +354,7 @@ class ReportAttendancegeneral(models.AbstractModel): def get_value(self, data): type = data['form']['type'] + shift_mode = data['form']['shift_mode'] totals_only = data["form"].get("print_totals_only", False) employee_ids = data['form']['employee_ids'] resource_calender_id = data['form']['resource_calender_id'] @@ -386,6 +393,11 @@ class ReportAttendancegeneral(models.AbstractModel): for key, value in grouped_data.items(): emp_data_dict[key] = list(value) if type == 'late': + if shift_mode != 'both': + if shift_mode == 'first': + attendance_transaction_ids = attendance_transaction_ids.filtered(lambda r: r.sequence == 1) + elif shift_mode == 'second': + attendance_transaction_ids = attendance_transaction_ids.filtered(lambda r: r.sequence == 2) for resource in attendance_transaction_ids: note = '' if resource.is_absent: @@ -500,6 +512,7 @@ class ReportAttendancegeneral(models.AbstractModel): start_date = data['form']['from_date'] end_date = data['form']['to_date'] type_ = data['form']['type'] + shift_mode = data['form']['shift_mode'] totals_only = data['form'].get('print_totals_only', False) summary_rows = [] @@ -515,6 +528,11 @@ class ReportAttendancegeneral(models.AbstractModel): domain.append(('employee_id', 'in', rc.employee_ids.ids)) att = self.env['hr.attendance.transaction'].search(domain) + if shift_mode != 'both': + if shift_mode == 'first': + att = att.filtered(lambda r: r.sequence == 1) + elif shift_mode == 'second': + att = att.filtered(lambda r: r.sequence == 2) for emp in att.mapped('employee_id'): # lines = att.filtered(lambda l, e=emp: l.employee_id == e)