diff --git a/soong_workflow/models/soong_note.py b/soong_workflow/models/soong_note.py index 66c690c10..8281b7527 100644 --- a/soong_workflow/models/soong_note.py +++ b/soong_workflow/models/soong_note.py @@ -12,6 +12,18 @@ class SoongNote(models.Model): note_setting_id = fields.Many2one('soong.note.setting', string="意见类型") create_note = fields.Char(string="创建信息", readonly=True) write_note = fields.Char(string="修改信息", readonly=True) + use_info = fields.Text(string="使用信息", readonly=True) + create_note_display = fields.Char(string="创建信息", compute='_compute_display_fields') + write_note_display = fields.Char(string="修改信息", compute='_compute_display_fields') + use_info_display = fields.Text(string="使用信息", compute='_compute_display_fields') + + @api.depends('create_note', 'write_note', 'use_info', 'name') + def _compute_display_fields(self): + for rec in self: + suffix = f"\n{rec.name}" if rec.name else '' + rec.create_note_display = (rec.create_note or '') + suffix + rec.write_note_display = (rec.write_note or '') + suffix + rec.use_info_display = (rec.use_info or '') + suffix def _format_user_time(self): """返回'当前用户名 YYYY-MM-DD HH:MM:SS'格式字符串(转换为东八区时间)""" diff --git a/soong_workflow/views/soong_note_views.xml b/soong_workflow/views/soong_note_views.xml index 19dede058..9f2789198 100644 --- a/soong_workflow/views/soong_note_views.xml +++ b/soong_workflow/views/soong_note_views.xml @@ -8,8 +8,9 @@ - - + + + diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard.py b/soong_workflow/wizard/soong_workflow_comment_wizard.py index 229ed3505..bdf4cacbd 100644 --- a/soong_workflow/wizard/soong_workflow_comment_wizard.py +++ b/soong_workflow/wizard/soong_workflow_comment_wizard.py @@ -406,6 +406,18 @@ class SoongWorkflowCommentWizard(models.TransientModel): def add_comment(self): self.ensure_one() self._send_workflow_notifications() + # 如果选择了常用意见,将使用信息追加到 soong.note 记录 + if self.comment_note_id: + import pytz + from datetime import datetime + tz = pytz.timezone('Asia/Shanghai') + today = datetime.now(pytz.utc).astimezone(tz).strftime('%Y-%m-%d') + user_name = self.env.user.name + code = self.code or '' + new_line = f"{today}\n{code}\n{user_name}" + old_info = self.comment_note_id.use_info or '' + updated_info = (old_info + '\n\n' + new_line) if old_info else new_line + self.comment_note_id.sudo().write({'use_info': updated_info}) cx = self.env.context.copy() or {} record_id = self.env[self.res_model].search([('id', '=', self.res_id)]) is_admin = self.env.user.has_group('soong_workflow.group_soong_workflow_manager')