考勤机

This commit is contained in:
李鹏宇
2026-09-08 10:13:57 +08:00
parent f0587e57fa
commit 78771fa5c2
2 changed files with 17 additions and 10 deletions
+6
View File
@@ -2,6 +2,7 @@
import base64
from odoo import models, fields, api, exceptions, _, tools
from odoo.exceptions import UserError
class HrEmployee(models.Model):
@@ -79,8 +80,13 @@ class HrEmployee(models.Model):
def action_attendance_iot_batch_copy(self):
# 「批量拷贝」按钮:打开弹窗,由用户手动勾选要同步到哪些考勤机
# 没勾选任何员工时直接提示,避免进入向导后 default_get 空记录报错
if not self:
raise UserError(_('请先在员工列表中勾选要同步的员工,再点击「批量拷贝」。'))
return self._get_attendance_iot_copy_action(sync_to_all=False)
def action_attendance_iot_sync_all(self):
# 「同步到全部设备」按钮:打开弹窗并默认带出本公司全部考勤机
if not self:
raise UserError(_('请先在员工列表中勾选要同步的员工,再点击「同步到全部设备」。'))
return self._get_attendance_iot_copy_action(sync_to_all=True)
@@ -23,19 +23,20 @@ class AttendanceIotImportUserWizard(models.TransientModel):
company_iots = self.env['attendance.iot'].search(
[('company_id', '=', company.id)])
res['attendance_iot_ids'] = [(6, 0, company_iots.ids)]
else:
elif self.env.context.get('active_ids'):
# 入口二:考勤机用户列表勾选进入,取第一条记录的源考勤机
active_ids = self.env.context.get('active_ids')
records = self.env['attendance.iot.user'].browse(active_ids)
# 取第一条记录,作为被拷贝的源考勤机
source_iot = records[0].attendance_iot_id
# 查出源考勤机所属公司的全部考勤机,作为同步目标默认带出(不排除源设备)
company_iots = self.env['attendance.iot'].search(
[('company_id', '=', source_iot.company_id.id)])
res.update({
'current_attendance_iot_id': source_iot.id,
'attendance_iot_ids': [(6, 0, company_iots.ids)],
})
if records:
# 取第一条记录,作为被拷贝的源考勤机
source_iot = records[0].attendance_iot_id
# 查出源考勤机所属公司的全部考勤机,作为同步目标默认带出(不排除源设备)
company_iots = self.env['attendance.iot'].search(
[('company_id', '=', source_iot.company_id.id)])
res.update({
'current_attendance_iot_id': source_iot.id,
'attendance_iot_ids': [(6, 0, company_iots.ids)],
})
return res
def action_import(self):