From af7007d6cfb1c11dec714b13fa5cbbd5e991bf5f Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Mon, 31 Mar 2025 09:40:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/hr_attendance_month.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/yuthon_hr_attendance/models/hr_attendance_month.py b/yuthon_hr_attendance/models/hr_attendance_month.py index 107d70e5c..a4ff803d8 100644 --- a/yuthon_hr_attendance/models/hr_attendance_month.py +++ b/yuthon_hr_attendance/models/hr_attendance_month.py @@ -415,11 +415,15 @@ class HrAttendanceMonthDetail(models.Model): def button_confirm(self): current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.user.id)], limit=1) - start_date,end_date = self._get_days(current_employee) + start_date,end_date, leave_start, leave_end= self._get_days(current_employee) leave = self._create_leave_record(start_date, end_date) day = leave.number_of_days leave.unlink() - work_day = self._process_shift_days(day,start_date,end_date) # 自然日中的工作日 + leave2 = self._create_leave_record(leave_start, leave_end) + day2 = leave2.number_of_days + leave2.unlink() + work_day = self._process_shift_days(day,start_date,end_date) # 当月的工作日 + work_day2 = self._process_shift_days(day2, leave_start, leave_end) # 请假期间的工作日 for record in self: current_year = record.current_year current_month = int(record.current_month) @@ -473,8 +477,8 @@ class HrAttendanceMonthDetail(models.Model): performance_deduction += (performance_bonuses / 21.75) * personal_leave # 产假 - commuting_deduction += (commuting_allowance / month_days) * work_day - performance_deduction += (performance_bonuses / month_days) * work_day + commuting_deduction += (commuting_allowance / work_day) * work_day2 + performance_deduction += (performance_bonuses / work_day) * work_day2 # 陪产假 paternity_leave = record.paternity_leave @@ -529,7 +533,7 @@ class HrAttendanceMonthDetail(models.Model): total_days += 1 return total_days - # 创建用户记录传入日期来获取天数(自然日中工作日的逻辑) + # 创建用户记录传入日期来获取天数(自然日中工作日的逻辑) def _create_leave_record(self, start_date, end_date): holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '年假')]) admin_id = self.env['hr.employee'].search([("name", "=", 'Administrator')]) @@ -540,11 +544,13 @@ class HrAttendanceMonthDetail(models.Model): 'request_date_to': end_date, 'state': 'confirm', }) - days = leave.number_of_days - return days - # 获得假种的当月开始日期结束日期 (目前先产假) def _get_days(self, employee_id): + """ + :param employee_id: 员工id + :return: start_date, end_date 员工当月工作日请假天数 + leave_start, leave_end 员工请假期间的工作日天数 + """ year = int(self.current_year) month = int(self.current_month) if month == 12: @@ -582,7 +588,7 @@ class HrAttendanceMonthDetail(models.Model): else: start_date = start_in_month end_date = end_in_month - return start_date,end_date + return start_date, end_date, leave_start, leave_end def _get_attendance_month_obj(self): """