[FIX] attendances

This commit is contained in:
Samir Ladoui 2025-08-04 14:32:19 +01:00
parent c486f1ab19
commit 5993413a0f
1 changed files with 18 additions and 0 deletions

View File

@ -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)