diff --git a/soong_workflow/models/soong_note.py b/soong_workflow/models/soong_note.py
index 3bbecdc0b..66c690c10 100644
--- a/soong_workflow/models/soong_note.py
+++ b/soong_workflow/models/soong_note.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
+from datetime import datetime
+import pytz
class SoongNote(models.Model):
@@ -8,6 +10,27 @@ class SoongNote(models.Model):
name = fields.Char(string="审批意见")
sequence = fields.Char(string='序号', store=True)
note_setting_id = fields.Many2one('soong.note.setting', string="意见类型")
+ create_note = fields.Char(string="创建信息", readonly=True)
+ write_note = fields.Char(string="修改信息", readonly=True)
+
+ def _format_user_time(self):
+ """返回'当前用户名 YYYY-MM-DD HH:MM:SS'格式字符串(转换为东八区时间)"""
+ user = self.env.user
+ tz = pytz.timezone('Asia/Shanghai')
+ now = datetime.now(pytz.utc).astimezone(tz).strftime('%Y-%m-%d %H:%M:%S')
+ return f"{user.name} {now}"
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ info = self._format_user_time()
+ for vals in vals_list:
+ vals['create_note'] = info
+ vals['write_note'] = info
+ return super().create(vals_list)
+
+ def write(self, vals):
+ vals['write_note'] = self._format_user_time()
+ return super().write(vals)
# type = fields.Selection([('agree', '同意'), ('return', '退回'), ('refuse', '拒绝'), ('super', '督办')],
# string="意见类型")
diff --git a/soong_workflow/views/soong_note_views.xml b/soong_workflow/views/soong_note_views.xml
index 2048ff194..19dede058 100644
--- a/soong_workflow/views/soong_note_views.xml
+++ b/soong_workflow/views/soong_note_views.xml
@@ -8,6 +8,8 @@
+
+