diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index d15f6e511..131d0f8ca 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -841,8 +841,6 @@ class HolidaysRequestBatch(models.Model): def _compute_holiday_allowance(self): current_date = fields.Date.today() current_year = current_date.year - year_start = fields.Date.from_string(f"{current_year}-01-01") - year_end = fields.Date.from_string(f"{current_year}-12-31") for record in self: record.holiday_allowance = "年假0.000天, 补休0.000天, 育儿假0.000天" diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py index c6f4a5c30..94beebc68 100644 --- a/yuthon_hr_attendance/models/overtime_approval.py +++ b/yuthon_hr_attendance/models/overtime_approval.py @@ -66,6 +66,7 @@ class OvertimeApprovals(models.Model): workflow_records = self.env['soong.workflow.record'].search([ ('workflow_id.name', '=', '加班'), ('create_uid', '=', self.env.user.id), + ('reclaim_state', '=', False), ]) if not workflow_records: continue diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index a03582da7..c1a19194b 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -272,7 +272,7 @@ class YuthonVacationReports(models.Model): record.year_sum = record.last_holiday + record.last_workday + record.year_holiday + record.year_workday record.remainder_year1 = record.last_holiday + record.last_workday + record.year_holiday + record.year_workday - record.used_this_year1 record.previous_year1 = record.last_holiday + record.last_workday - record.this_year1 = record.year_holiday + record.year_workday + record.this_year1 = record.year_holiday + record.year_workday - record.used_this_year1 @api.constrains('employee_id', 'vacation_date') def _check_duplicate_monthly_record(self): @@ -743,6 +743,15 @@ class YuthonVacationReports(models.Model): if rec.working_overtime: overtime_hours = rec.working_overtime * 8 self._update_over_lines(rec, [rec], overtime_hours) + if rec.remaining_parental_leave and last_month_record.parenting_line_ids: + update_date = last_month_record.parenting_line_ids[0].update_date + end_date = last_month_record.parenting_line_ids[0].end_date + if rec.end_date: + date_condition = update_date <= rec.vacation_date <= end_date + else: + date_condition = rec.vacation_date >= update_date + if date_condition: + self._update_parental_leave_lines(rec, [rec], rec.remaining_parental_leave, update_date, end_date) @api.depends('medical_fee_ids.update_type', 'medical_fee_ids.lines', 'medical_fee_ids.is_void') def _compute_medical_fee(self): @@ -1026,6 +1035,24 @@ class YuthonVacationReports(models.Model): 'text': f"上月额度继承" }) + def _update_parental_leave_lines(self, report, allocations, number_of_hours_display, update_date, end_date): + for alloc in allocations: + existing_line = self.env['vacation.parenting.line'].search([ + ('vacation_id', '=', report.id), + ('employee_id', '=', report.employee_id.id), + ('text', '=', '上月额度继承'), + ], limit=1) + if existing_line: + continue + self.env['vacation.parenting.line'].create({ + 'vacation_id': report.id, + 'employee_id': report.employee_id.id, + 'update_date': update_date, + 'end_date': end_date, + 'lines': number_of_hours_display, + 'text': f"上月额度继承", + }) + def log(self): return { "type": "ir.actions.act_window", diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index bc7352558..2d128c6c4 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -940,29 +940,6 @@ class YuthonHrEmployee(models.Model): holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '育儿假')], limit=1) # 更新报表 parenting_line_ids = [] - reports_id = self.env['yuthon.vacation.reports'].search([ - ('employee_id', '=', employee.id), - ('vacation_date', '=', fields.Date.today().replace(day=1)) - ], limit=1) # - if reports_id: - existing_line = reports_id.parenting_line_ids.search([ - ('vacation_id', '=', reports_id.id), - ('employee_id', '=', employee.id), - ('update_date', '=', date_from), - ('end_date', '=', date_to), - ('text','=', '育儿假分配') - ], limit=1) - if not existing_line: - parenting_line_ids.append([0, 0, { - 'vacation_id': reports_id.id, - 'employee_id': employee.id, - 'update_date': date_from, - 'end_date': date_to, - 'lines': total_days, - 'text': '育儿假分配' - }]) - if parenting_line_ids : - reports_id.write({'parenting_line_ids': parenting_line_ids}) # 6. 检查是否已存在相同分配记录,避免重复 existing_allocation = self.env['hr.leave.allocation'].search([ @@ -974,6 +951,20 @@ class YuthonHrEmployee(models.Model): ], limit=1) if existing_allocation: continue + + reports_id = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', employee.id), + ('vacation_date', '=', fields.Date.today().replace(day=1)) + ], limit=1) # + if reports_id: + reports_id.parenting_line_ids.search([ + ('vacation_id', '=', reports_id.id), + ('employee_id', '=', employee.id), + ('update_date', '=', date_from), + ('end_date', '=', date_to), + ('text','=', '育儿假分配') + ], limit=1) + self.env['hr.leave.allocation'].create({ 'name': '育儿假分配', 'allocation_type': 'regular',