diff --git a/yuthon_holiday/models/extended_vacation_approval.py b/yuthon_holiday/models/extended_vacation_approval.py index effecc58e..09952f3de 100644 --- a/yuthon_holiday/models/extended_vacation_approval.py +++ b/yuthon_holiday/models/extended_vacation_approval.py @@ -62,7 +62,6 @@ class ExtendedVacationApproval(models.Model): if self.employee_ids: has_annual_leave = self.type_vacations_ids.filtered(lambda r: r.name == '年假') has_overtime_leave = self.type_vacations_ids.filtered(lambda r: r.name == '补休') - for employee in self.employee_ids: report_records = self.env['yuthon.vacation.reports'].search([ ('employee_id', '=', employee.id), diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index b44fd06ee..2a041e9d9 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -377,17 +377,33 @@ class YuthonVacationReports(models.Model): rec.year_workday += workday_overtime_add rec.year_holiday += holidays_overtime_add - if (rec.dynamic_previous_year1 + rec.this_year1) > 0: + current_month_first = rec.vacation_date.replace(day=1) + last_month_last = current_month_first - timedelta(days=1) + last_month_first = last_month_last.replace(day=1) + last_month_record = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', rec.employee_id.id), + ('vacation_date', '=', last_month_first), + ], limit=1) + if last_month_record: + total_overtime = last_month_record.dynamic_previous_year1 + last_month_record.this_year1 + else: + total_overtime = 0.0 + + if total_overtime > 0: working_overtime_lines = rec.overtime_ids.filtered( lambda o: not o.workflow_record_id and o.text == '上月额度继承' ) - working_overtime_lines.workday = (rec.dynamic_previous_year1 + rec.this_year1) * 8 + working_overtime_lines.workday = total_overtime * 8 + if last_month_record: + total_leave = last_month_record.dynamic_previous_year + last_month_record.dynamic_remainder_year + else: + total_leave = 0.0 - if (rec.dynamic_previous_year + rec.dynamic_remainder_year) > 0: + if total_leave > 0: leave_lines = rec.leave_ids.filtered( lambda o: not o.workflow_record_id and o.text == '上月额度继承' ) - leave_lines.update_lines = (rec.dynamic_previous_year + rec.dynamic_remainder_year) * 8 + leave_lines.update_lines = total_leave * 8 rec._compute_leave() rec._compute_working_overtime()