diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index d197c8ed2..9cde87af2 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -147,7 +147,15 @@ class YuthonVacationReports(models.Model): month_start = date(year, month, 1) month_end = date(year, month, days_in_month) leave_days = rec._create_leave_record(rec.employee_id, month_start, month_end) - for day in range(1, days_in_month + 1): + entry_date = rec.employee_id.entry_date + if month_start > entry_date: + start_day = 1 + else: + days_in_month = (date(year, month + 1, 1) - timedelta(days=1)).day + start_day = min(entry_date.day, days_in_month) + days_in_month = (date(year, month + 1, 1) - timedelta(days=1)).day + actual_days_range = range(start_day, days_in_month + 1) + for day in actual_days_range: current_date = date(year, month, day) attendances = self.env["hr.attendance"].sudo().search([ ('employee_id', '=', rec.employee_id.id),