diff --git a/attendance_iot/models/attendance_iot.py b/attendance_iot/models/attendance_iot.py index 43e352b32..dfc14e693 100644 --- a/attendance_iot/models/attendance_iot.py +++ b/attendance_iot/models/attendance_iot.py @@ -9,9 +9,10 @@ _logger = logging.getLogger(__name__) class AttendanceIot(models.Model): _name = 'attendance.iot' _description = '考勤机设备' - _rec_name = 'name' + _rec_name = 'display_name' name = fields.Char(string="设备号") + display_name = fields.Char(string="名称", compute='_compute_display_name', store=True) attendance_address = fields.Char(string="设备地址") broker = fields.Char(string='服务器地址/ip') port = fields.Char(string='端口号') @@ -23,6 +24,18 @@ class AttendanceIot(models.Model): is_connected = fields.Boolean(string="连接状态", default=False) last_update_time = fields.Datetime(string="最后更新时间") + @api.depends('company_id', 'attendance_address', 'name') + def _compute_display_name(self): + for r in self: + parts = [] + if r.company_id: + parts.append(r.company_id.name) + if r.attendance_address: + parts.append(r.attendance_address) + if r.name: + parts.append(r.name) + r.display_name = ' - '.join(parts) if parts else r.name or '' + def action_init_device(self): ''' 初始化设备数据 diff --git a/attendance_iot/views/attendance_iot_views.xml b/attendance_iot/views/attendance_iot_views.xml index 149892e36..52c39515d 100644 --- a/attendance_iot/views/attendance_iot_views.xml +++ b/attendance_iot/views/attendance_iot_views.xml @@ -8,7 +8,8 @@
- + + @@ -38,6 +39,7 @@
+