diff --git a/yuthon_holiday/models/inherit_hr_leave_allocation.py b/yuthon_holiday/models/inherit_hr_leave_allocation.py index 087717e63..6717528d7 100644 --- a/yuthon_holiday/models/inherit_hr_leave_allocation.py +++ b/yuthon_holiday/models/inherit_hr_leave_allocation.py @@ -179,7 +179,7 @@ class HrLeaveAllocation(models.Model): def update_vacation(self): leave_ids = self.env["hr.leave.allocation"].browse( self._context.get('active_ids', self._context.get('active_id'))) - date = datetime(2025, 11, 1) # 修改为你的日期 + date = datetime(2025, 10, 1) # 修改为你的日期 for leave in leave_ids: leave_list = [] compensatory_list = [] @@ -195,7 +195,7 @@ class HrLeaveAllocation(models.Model): 'update_lines': leave.number_of_days * 8, 'text': leave.name }]) - if leave.holiday_status_id.name == '补休': + elif leave.holiday_status_id.name == '补休': compensatory_list.append([0, 0, { 'vacation_id': reports_id.id, 'employee_id': reports_id.employee_id.id, @@ -214,7 +214,7 @@ class HrLeaveAllocation(models.Model): 'employee_id': leave.employee_id.id, 'update_date': fields.Date.today(), 'update_type': 'add', - 'lines': leave.number_of_days, + 'lines': leave.number_of_hours_display / 8, 'text': leave.name }]) if not reports_id: diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index 9e821fe19..44206c4d6 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -653,11 +653,24 @@ class YuthonVacationReports(models.Model): for rec in vacation_ids: rec.vacation_state = 'confirmed' + # 自动确认考勤台账 def automatic_confirmation(self): current_date = fields.Date.today() - vacation_ids = self.env["yuthon.vacation.reports"].search(['vacation_date', '=', current_date.replace(day=1)]) + vacation_ids = self.env["yuthon.vacation.reports"].search([ + ('vacation_date', '=', current_date.replace(day=1)) + ]) for rec in vacation_ids: - rec.manage_reject() + month_start = current_date.replace(day=1) + month_end = (month_start + relativedelta(months=1) - relativedelta(days=1)) + attendance_exception = self.env['hr.attendance'].search([ + ('employee_id', '=', rec.employee_id.id), + ('current_data', '>=', month_start), + ('current_data', '<=', month_end), + ('is_abnormal', '=', True) + ], limit=1) + # 如果考勤异常,则不自动确认 + if not attendance_exception: + rec.manage_reject() def monthly_report(self): today = fields.Date.today() @@ -672,7 +685,8 @@ class YuthonVacationReports(models.Model): existing_record = self.search([ ('employee_id', '=', employee.id), - ('vacation_date', '=', today) + ('vacation_date', '=', today), + ('vacation_state', '=', 'unconfirmed') ], limit=1) if not existing_record or not is_resource_user: