From 0b40fc154d27ce9b4aa5cce8008f11232e71f25a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Wed, 2 Sep 2026 15:29:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/yuthon_vacation_reports.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index e886a5409..10950b806 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -2999,15 +2999,26 @@ class YuthonVacationReports(models.Model): if not user: return False, '' - # 查找当月考勤分组下 users_ids 包含当前用户的未办结流程 - pending_records = self.env['soong.workflow.record'].sudo().search([ - ('users_ids', 'in', user.id), + # 基础域:当月考勤分组下未办结流程 + base_domain = [ ('approvals_group_id.name', '=', '考勤'), ('reclaim_state', '=', False), ('approve_state', '=', 'pending'), ('workflow_happen_date', '>=', month_start), ('workflow_happen_date', '<=', month_end), - ]) + ] + # 查找当月考勤分组下 users_ids 包含当前用户的未办结流程 + pending_records = self.env['soong.workflow.record'].sudo().search([ + ('users_ids', 'in', user.id), + ] + base_domain) + + # 加班特殊处理:加班人(employee_ids many2many)并不写入 record.users_ids, + # 仅按 users_ids 搜索会漏掉"本人是加班人但不在 users_ids 中"的加班流程, + # 导致该加班人也能确认考勤。故额外捞出当月"加班"流程,下方按加班人字段判定当事人。 + overtime_records = self.env['soong.workflow.record'].sudo().search([ + ('workflow_id.name', '=', '加班'), + ] + base_domain) + pending_records |= overtime_records # 合并并去重(recordset 自动去重) pending_codes = [] for record in pending_records: workflow_name = record.workflow_id.name