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: