From e0494ce20f8faa8e34f609ca9f361516ff384944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Fri, 6 Feb 2026 16:59:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E6=94=BF=E5=8F=91=E6=96=87=E5=8A=A0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_official/models/yuthon_official.py | 9 +++++++++ yuthon_official/views/yuthon_official_views.xml | 8 ++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/yuthon_official/models/yuthon_official.py b/yuthon_official/models/yuthon_official.py index f8baca6f0..5c9012bf8 100644 --- a/yuthon_official/models/yuthon_official.py +++ b/yuthon_official/models/yuthon_official.py @@ -12,6 +12,7 @@ class YuthonOfficial(models.Model): _rec_name = 'name' name = fields.Char(string="标题") + text = fields.Text(string="标题", compute='_compute_text', store=True) code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('official_code')) official_type_id = fields.Many2one('official.type', string="文件类型") is_cold = fields.Boolean(string="发文编号") @@ -77,6 +78,14 @@ class YuthonOfficial(models.Model): name_title = fields.Char(default=_get_default_name_title) self_users_ids = fields.Many2many('res.users', string="当前经办人", default=lambda self: [(6, 0, [self.env.user.id])]) + @api.depends('name') + def _compute_text(self): + """ + 计算text字段,值等于name字段 + """ + for record in self: + record.text = record.name or '' + def end_approval(self): self.write({'work_end': True}) diff --git a/yuthon_official/views/yuthon_official_views.xml b/yuthon_official/views/yuthon_official_views.xml index d362e7cfb..b0f8bd899 100644 --- a/yuthon_official/views/yuthon_official_views.xml +++ b/yuthon_official/views/yuthon_official_views.xml @@ -5,8 +5,12 @@ yuthon.official - - + + + + + +