Merge branch 'dev' of gitee.com:jinan-pengyusen-data/gzth into dev

This commit is contained in:
sunjie
2025-07-25 08:50:14 +08:00
2 changed files with 21 additions and 17 deletions
+18 -16
View File
@@ -14,26 +14,28 @@ class AttendanceIotUser(models.Model):
company_id = fields.Many2one(related='employee_id.company_id', string="公司")
id_valid = fields.Date(string="有效日期")
# 从 employee_id 获取.
image_1920 = fields.Many2one('ir.attachment', string="一寸照")
image_1920 = fields.Many2one('ir.attachment', related='employee_id.avatar_image', string="一寸照")
department_id = fields.Many2one('hr.department_id', related='employee_id.department_id', string="部门")
mobile_phone = fields.Char('hr.department_id', related='employee_id.company_id', string="电话")
iot_user_id = fields.Char(string='设备上用户的编码')
_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
@@ -9,9 +9,11 @@
<button name="%(action_attendance_iot_import_user_wizard_form)d" string="批量拷贝" type="action" />
</header>
<field name="employee_id"/>
<field name="department_id"/>
<field name="mobile_phone"/>
<field name="attendance_iot_id" string="设备号"/>
<field name="attendance_address"/>
<!-- <field name="image_1920"/>-->
<field name="avatar_image" widget="image" options="{'size':[70,150]}"/>
<field name="company_id" column_invisible="1"/>
</tree>
</field>