From 83ae6258b5c9b8bb994cfceea4470188f86a8e5f Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Thu, 8 May 2025 10:21:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_notice/data/notice_code_data.xml | 2 +- yuthon_notice/models/yuthon_notice.py | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/yuthon_notice/data/notice_code_data.xml b/yuthon_notice/data/notice_code_data.xml index d6bfa7ed5..69a095092 100644 --- a/yuthon_notice/data/notice_code_data.xml +++ b/yuthon_notice/data/notice_code_data.xml @@ -3,7 +3,7 @@ 通知公告编号 notice_code - TZ + TZ%(y)s%(month)s%(day)s 3 diff --git a/yuthon_notice/models/yuthon_notice.py b/yuthon_notice/models/yuthon_notice.py index b639a37e8..db2e832b6 100644 --- a/yuthon_notice/models/yuthon_notice.py +++ b/yuthon_notice/models/yuthon_notice.py @@ -13,7 +13,7 @@ class YuthonNotice(models.Model): _order = "sequence desc" name = fields.Char(string='标题') - code = fields.Char(string="编号", default=lambda self: self._get_default_code()) + code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('notice_code')) users_id = fields.Many2one('res.users', string="发布人", default=lambda self: self.env.user) department_id = fields.Many2one(related='users_id.employee_id.department_id', string="部门") notice_type_id = fields.Many2one('yuthon.notice.type', string="类型") @@ -41,11 +41,6 @@ class YuthonNotice(models.Model): active = fields.Boolean('Active', default=True, tracking=True) work_end = fields.Boolean(string="结束") - def _get_default_code(self): - sequence_code = self.env['ir.sequence'].next_by_code('notice_code') - _logger.info("Generated sequence code: %s", sequence_code) - return sequence_code - @api.model_create_multi def create(self, vals_list): for i in vals_list: