!12458 添加功能

Merge pull request !12458 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2026-07-20 03:53:51 +00:00
committed by Gitee
2 changed files with 13 additions and 6 deletions
+9 -6
View File
@@ -502,7 +502,7 @@ class HolidaysRequestBatch(models.Model):
# 年假以小时为单位(天数 * 8)
self._create_annual_leave_line(period_start=period['start'], leave_data=leave, hours=days * 8, period=period)
else:
self._create_other_leave_line(period_start=period['start'], leave_data=leave, days=days, period=period, leave_type_name=leave_type_name)
self._create_other_leave_line(period_start=period['start'], leave_data=leave, hours=days * 8, period=period, leave_type_name=leave_type_name)
# 更新考勤
self.update_attendance(self.users_id.employee_id, leave['start'], leave['end'], self.code)
@@ -518,7 +518,7 @@ class HolidaysRequestBatch(models.Model):
self._create_overtime_leave_line(period_start=leave_date, leave_data=leave, hours=hours, period={'start': leave_date, 'end': leave_date}, leave_type_name=leave_type_name)
else:
# 其他类型小时假,使用天数
self._create_other_leave_line(period_start=leave_date, leave_data=leave, days=leave['days'], period={'start': leave_date, 'end': leave_date}, leave_type_name=leave_type_name)
self._create_other_leave_line(period_start=leave_date, leave_data=leave, hours=hours, period={'start': leave_date, 'end': leave_date}, leave_type_name=leave_type_name)
# 更新考勤
self.update_attendance(self.users_id.employee_id, leave_date, leave_date, self.code)
@@ -825,12 +825,12 @@ class HolidaysRequestBatch(models.Model):
for rep in future_reps:
rep.update_line()
def _create_other_leave_line(self, period_start, leave_data, days, period, leave_type_name):
def _create_other_leave_line(self, period_start, leave_data, hours, period, leave_type_name):
"""
创建其他假减记录(跨月自动拆分)
:param period_start: 原始周期开始时间(datetime.date)
:param leave_data: 请假数据字典(含workflow_id等)
:param days: 总请假天数(浮点型)
:param hours: 总请假天数(浮点型)
:param period: 请假时间段 {'start': date, 'end': date}
:param leave_type_name: 假期类型名称
"""
@@ -860,7 +860,10 @@ class HolidaysRequestBatch(models.Model):
for interval in month_intervals:
interval_start = interval['start']
interval_end = interval['end']
interval_days = self._compute_duration_day(holiday_type, interval_start, interval_end)
if self.is_hour:
interval_hours = hours
else:
interval_hours = self._compute_duration_day(holiday_type, interval_start, interval_end)
period_start = interval['period_start']
vacation_report1 = self.env['yuthon.vacation.reports'].search([
('employee_id', '=', employee_id),
@@ -888,7 +891,7 @@ class HolidaysRequestBatch(models.Model):
'employee_id': employee_id,
'workflow_record_id': leave_data.get('workflow_id', False),
'update_type': 'reduce',
'lines': interval_days,
'lines': interval_hours,
'holiday_type': holiday_type.id,
'update_date': fields.Date.today(),
'is_void': False,
@@ -405,6 +405,10 @@ class YuthonVacationReports(models.Model):
self_parental_leave = rec.parenting_line_ids.filtered(lambda o: o.text == '上月额度继承')
self_parental_leave.unlink()
# 如果上个月加班是0 删除明细
if rec.self_overtime.workday == 0:
self_overtime.unlink()
add_overtime_lines = rec.overtime_ids.filtered(
lambda o: o.text != '上月额度继承' and o.update_type == 'add' and o.is_void != True)
# 计算补休新增总天数