From dbbbfa4455a80eaba016e6f71f9723d01f76c085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Wed, 4 Mar 2026 11:28:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=E7=A1=AE=E8=AE=A4=E5=8D=95?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/yuthon_vacation_reports.py | 38 +++++++++++++++++++ .../views/yuthon_vacation_reports_views.xml | 6 ++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index b573e2c36..b5099ac09 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -669,6 +669,44 @@ class YuthonVacationReports(models.Model): f"已存在假期额度记录,不能重复创建!" ) + def action_prev_month(self): + """跳转到上一个月的假期记录""" + self.ensure_one() + prev_date = (self.vacation_date - relativedelta(months=1)).replace(day=1) + prev_record = self.search([ + ('employee_id', '=', self.employee_id.id), + ('vacation_date', '=', prev_date), + ], limit=1) + if not prev_record: + raise UserError('上一个月没有对应的假期记录') + action = self.env['ir.actions.actions']._for_xml_id('yuthon_hr_attendance.view_yuthon_vacation_reports_action') + action.update({ + 'res_id': prev_record.id, + 'views': [(False, 'form')], + 'view_mode': 'form', + 'target': 'current', + }) + return action + + def action_next_month(self): + """跳转到下一个月的假期记录""" + self.ensure_one() + next_date = (self.vacation_date + relativedelta(months=1)).replace(day=1) + next_record = self.search([ + ('employee_id', '=', self.employee_id.id), + ('vacation_date', '=', next_date), + ], limit=1) + if not next_record: + raise UserError('下一个月没有对应的假期记录') + action = self.env['ir.actions.actions']._for_xml_id('yuthon_hr_attendance.view_yuthon_vacation_reports_action') + action.update({ + 'res_id': next_record.id, + 'views': [(False, 'form')], + 'view_mode': 'form', + 'target': 'current', + }) + return action + def action_open(self): self.ensure_one() target_date = self.vacation_date.replace(day=1) diff --git a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml index d43a29a1c..231128d5f 100644 --- a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml +++ b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml @@ -180,10 +180,12 @@ -
-

+
+