审批意见创建修改记录

This commit is contained in:
李鹏宇
2026-03-16 11:57:31 +08:00
parent 659e726a79
commit 2456f86ba2
3 changed files with 27 additions and 2 deletions
+12
View File
@@ -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'格式字符串(转换为东八区时间)"""
+3 -2
View File
@@ -8,8 +8,9 @@
<field name="sequence" widget="handle"/>
<field name="name" required="1"/>
<field name="note_setting_id"/>
<field name="create_note" readonly="1"/>
<field name="write_note" readonly="1"/>
<field name="create_note_display" readonly="1"/>
<field name="write_note_display" readonly="1"/>
<field name="use_info_display" readonly="1"/>
</tree>
</field>
</record>
@@ -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')