diff --git a/yuthon_holiday/models/inherit_hr_leave_allocation.py b/yuthon_holiday/models/inherit_hr_leave_allocation.py index c03fed3cd..b0adbb7fc 100644 --- a/yuthon_holiday/models/inherit_hr_leave_allocation.py +++ b/yuthon_holiday/models/inherit_hr_leave_allocation.py @@ -190,6 +190,16 @@ class HrLeaveAllocation(models.Model): if leave.holiday_status_id.name == '年假': current_leave_hours = leave.number_of_days * 8 + existing_leave_line = False + if reports_id and reports_id.leave_ids: + existing_leave_line = reports_id.leave_ids.filtered( + lambda l: l.text == '上月额度继承' + )[:1] + if existing_leave_line: + update_leave_vals = { + 'valid_date': leave.date_to, + } + existing_leave_line.write(update_leave_vals) leave_list.append([0, 0, { 'vacation_id': reports_id.id, 'update_type': 'add', diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py index 2cd44ca33..7f1e7a8ca 100644 --- a/yuthon_hr_attendance/models/overtime_approval.py +++ b/yuthon_hr_attendance/models/overtime_approval.py @@ -317,16 +317,24 @@ class OvertimeApprovals(models.Model): }) reports_id.write({'meal_fee_ids': [meal_fee_value]}) - # 查找下个月的记录 如果有的话 加到本年剩余(补休)里面 + # 查找下个月的记录 如果有的话 加到明细的上月继承额度里面 start_date = fields.Date.to_date(self.start_time) + relativedelta(months=1) vacation_next_date = start_date.replace(day=1) reports_next_id = self.env['yuthon.vacation.reports'].search([ ('employee_id', '=', employee_id.id), ('vacation_date', '=', vacation_next_date) ]) - if reports_next_id: - reports_next_id.year_workday += record.duration / 8 - + existing_line = self.env['vacation.over.line'].search([ + ('vacation_id', '=', reports_next_id.id), + ('employee_id', '=', reports_next_id.employee_id.id), + ('text', '=', '上月额度继承'), + ], limit=1) + if existing_line: + existing_line.write({ + 'workday': workday, + 'legal_day': legal_day, + 'public_holidays': public_holidays, + }) start_date = fields.Date.to_date(self.start_time) end_date = fields.Date.to_date(self.end_time) attendance_records = self.env['hr.attendance'].search([ diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index 86bfeea2a..d55bd94f0 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -688,12 +688,13 @@ class YuthonVacationReports(models.Model): total_add1 = 0.0 total_add2 = 0.0 total_add = 0.0 - + legal_total = 0.0 for line in record.overtime_ids: if line.is_void: continue - line_total = (line.workday or 0) + (line.legal_day or 0) + (line.public_holidays or 0) + line_total = (line.workday or 0) + (line.public_holidays or 0) + (line.legal_day or 0) + legal_total += (line.legal_day or 0) if line.update_type == 'add': total_add += line_total elif line.update_type == 'reduce': @@ -710,6 +711,7 @@ class YuthonVacationReports(models.Model): record.working_overtime = max(total_add / 8, 0) + adjust_holiday_days record.done_working_overtime = total_add1 / 8 + record.legal_total = legal_total/8 record.cop_leave = total_add2 / 8 @api.depends('meal_fee_ids.update_lines', 'meal_fee_ids.update_type', 'meal_fee_ids.is_void')