From e8f86bbe729cfb2fb2dff5641ce824dd4c059429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Tue, 8 Sep 2026 11:34:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- attendance_iot/wizard/attendance_iot_import_user_wizard.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/attendance_iot/wizard/attendance_iot_import_user_wizard.py b/attendance_iot/wizard/attendance_iot_import_user_wizard.py index 00b6ec646..95ed7a29f 100644 --- a/attendance_iot/wizard/attendance_iot_import_user_wizard.py +++ b/attendance_iot/wizard/attendance_iot_import_user_wizard.py @@ -18,7 +18,8 @@ class AttendanceIotImportUserWizard(models.TransientModel): if employee_ids: # 入口一:员工列表按钮进入,取第一个选中员工的关联考勤机作为源设备 source_employee = self.env['hr.employee'].browse(employee_ids[0]) - source_iots = source_employee.attendance_iot_ids + # 用 .exists() 过滤掉已删除的孤儿记录(避免访问已删 attendance.iot 报「缺失记录」) + source_iots = source_employee.attendance_iot_ids.exists() if source_iots: # 取第一个关联考勤机为源设备:上方显示源设备,下方带出同公司其余考勤机(排除源设备,避免重复) source_iot = source_iots[0] @@ -36,7 +37,8 @@ class AttendanceIotImportUserWizard(models.TransientModel): elif self.env.context.get('active_ids'): # 入口二:考勤机用户列表勾选进入,取第一条记录的源考勤机 active_ids = self.env.context.get('active_ids') - records = self.env['attendance.iot.user'].browse(active_ids) + # 用 .exists() 过滤掉已删除的孤儿记录 + records = self.env['attendance.iot.user'].browse(active_ids).exists() if records: # 取第一条记录,作为被拷贝的源考勤机 source_iot = records[0].attendance_iot_id