diff --git a/attendance_iot/models/attendance_iot.py b/attendance_iot/models/attendance_iot.py
index 8deec42e7..21d4a2e43 100644
--- a/attendance_iot/models/attendance_iot.py
+++ b/attendance_iot/models/attendance_iot.py
@@ -18,6 +18,21 @@ class AttendanceIot(models.Model):
company_id = fields.Many2one('res.company', string="公司")
employee_ids = fields.Many2many('hr.employee', string="员工")
+ def action_init_device(self):
+ '''
+ 初始化设备数据
+ '''
+ # 查找 员工
+ for record in self:
+ values = []
+ employees = self.env['hr.employee'].search([('company_id', '=', record.company_id.id)])
+ for employee in employees:
+ values.append({
+ 'employee_id': employee.id,
+ 'attendance_iot_id': record.id
+ })
+ self.env['attendance.iot.user'].create(values)
+
def open_record(self):
self.ensure_one()
return {
@@ -26,7 +41,7 @@ class AttendanceIot(models.Model):
'res_model': 'attendance.iot.user',
'view_mode': 'tree',
'domain': [('attendance_iot_id', '=', self.id)],
- 'context':{'default_attendance_iot_id':self.id}
+ 'context': {'default_attendance_iot_id': self.id}
}
def compute_iot_num(self):
diff --git a/attendance_iot/views/attendance_iot_views.xml b/attendance_iot/views/attendance_iot_views.xml
index 5dad42339..e94ae66d4 100644
--- a/attendance_iot/views/attendance_iot_views.xml
+++ b/attendance_iot/views/attendance_iot_views.xml
@@ -5,11 +5,14 @@
attendance.iot
+
-
-
-
+
+
+