From d5b0dff4d2ce116c48c43c9568922d7f24f012ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Tue, 2 Jun 2026 10:11:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=E6=9C=BA=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- attendance_iot/models/attendance_iot.py | 15 ++++++++++++++- attendance_iot/views/attendance_iot_views.xml | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) 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 @@
+