考勤机
This commit is contained in:
@@ -16,24 +16,23 @@ class AttendanceIotImportUserWizard(models.TransientModel):
|
||||
# 入口一:员工列表按钮进入,context 带了选中的员工 id 列表
|
||||
employee_ids = self.env.context.get('default_employee_ids')
|
||||
if employee_ids:
|
||||
# 源公司:第一个选中员工的公司
|
||||
# 入口一:员工列表按钮进入,取第一个选中员工的关联考勤机作为源设备
|
||||
source_employee = self.env['hr.employee'].browse(employee_ids[0])
|
||||
company = source_employee.company_id
|
||||
# 取第一个员工已关联的考勤机(如「本部3楼」),作为源设备
|
||||
source_iots = source_employee.attendance_iot_ids
|
||||
# 「同步到全部设备」时才默认带出
|
||||
if self.env.context.get('default_sync_to_all'):
|
||||
if source_iots:
|
||||
# 有已关联考勤机:上方显示第一个源设备,下方带出公司其余考勤机(排除源设备)
|
||||
res['current_attendance_iot_id'] = source_iots[0].id
|
||||
company_iots = self.env['attendance.iot'].search(
|
||||
[('company_id', '=', company.id), ('id', 'not in', source_iots.ids)])
|
||||
res['attendance_iot_ids'] = [(6, 0, company_iots.ids)]
|
||||
else:
|
||||
# 该员工未关联任何考勤机:下方带出公司全部考勤机
|
||||
company_iots = self.env['attendance.iot'].search(
|
||||
[('company_id', '=', company.id)])
|
||||
res['attendance_iot_ids'] = [(6, 0, company_iots.ids)]
|
||||
if source_iots:
|
||||
# 取第一个关联考勤机为源设备:上方显示源设备,下方带出同公司其余考勤机(排除源设备,避免重复)
|
||||
source_iot = source_iots[0]
|
||||
company_iots = self.env['attendance.iot'].search(
|
||||
[('company_id', '=', source_iot.company_id.id), ('id', '!=', source_iot.id)])
|
||||
res.update({
|
||||
'current_attendance_iot_id': source_iot.id,
|
||||
'attendance_iot_ids': [(6, 0, company_iots.ids)],
|
||||
})
|
||||
else:
|
||||
# 员工未关联任何考勤机:下方带出公司全部考勤机
|
||||
company_iots = self.env['attendance.iot'].search(
|
||||
[('company_id', '=', source_employee.company_id.id)])
|
||||
res['attendance_iot_ids'] = [(6, 0, company_iots.ids)]
|
||||
elif self.env.context.get('active_ids'):
|
||||
# 入口二:考勤机用户列表勾选进入,取第一条记录的源考勤机
|
||||
active_ids = self.env.context.get('active_ids')
|
||||
@@ -41,7 +40,7 @@ class AttendanceIotImportUserWizard(models.TransientModel):
|
||||
if records:
|
||||
# 取第一条记录,作为被拷贝的源考勤机
|
||||
source_iot = records[0].attendance_iot_id
|
||||
# 查出源考勤机所属公司的全部考勤机,排除源设备本身(避免和上方重复)
|
||||
# 查出源考勤机所属公司的其余考勤机(排除源设备本身,避免和上方重复)
|
||||
company_iots = self.env['attendance.iot'].search(
|
||||
[('company_id', '=', source_iot.company_id.id), ('id', '!=', source_iot.id)])
|
||||
res.update({
|
||||
|
||||
Reference in New Issue
Block a user