@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user