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 - - + + + + + +