This commit is contained in:
李鹏宇
2025-07-25 08:35:16 +08:00
parent 7c55bcfd3f
commit c5078a62ed
+15 -15
View File
@@ -19,21 +19,21 @@ class AttendanceIotUser(models.Model):
_sql_constraints = [('unique','UNIQUE(attendance_iot_id,employee_id)','一台设备不允许上传相同的员工信息')]
def unlink(self):
if not self._context.get('iot_sync'):
# 下发删除信息
iot_id = self[0].attendance_iot_id.name
# 如果是主动下发的客户,则使用 employee_id.id 作为用户的编码
self.env['iot.message'].create([{
'name': '删除用户',
'topic': f'iot/device/{iot_id}',
'device_sn': iot_id,
'message_data': json.dumps({
'cmd': 'delMultiUser',
'user_ids': [x.iot_user_id if x.iot_user_id else f'bd{x.employee_id.mobile_phone}' for x in self]
}, ensure_ascii=False)
}])
return super(AttendanceIotUser, self).unlink()
# def unlink(self):
# if not self._context.get('iot_sync'):
# # 下发删除信息
# iot_id = self[0].attendance_iot_id.name
# # 如果是主动下发的客户,则使用 employee_id.id 作为用户的编码
# self.env['iot.message'].create([{
# 'name': '删除用户',
# 'topic': f'iot/device/{iot_id}',
# 'device_sn': iot_id,
# 'message_data': json.dumps({
# 'cmd': 'delMultiUser',
# 'user_ids': [x.iot_user_id if x.iot_user_id else f'bd{x.employee_id.mobile_phone}' for x in self]
# }, ensure_ascii=False)
# }])
# return super(AttendanceIotUser, self).unlink()
@api.model_create_multi