From dc89aba05bffcf0b93ddd140044c7a7139534389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Mon, 16 Mar 2026 10:50:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=89=B9=E6=84=8F=E8=A7=81=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BF=AE=E6=94=B9=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- soong_workflow/models/soong_note.py | 23 +++++++++++++++++++++++ soong_workflow/views/soong_note_views.xml | 2 ++ 2 files changed, 25 insertions(+) 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 @@ + +