From a557a42cf526a0cad94651e54f50c7ebba8e977f Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Mon, 17 Jul 2023 10:40:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E5=B7=A5=E4=BD=9C=E6=97=A5=E5=8E=86?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9A=84name=E5=AD=97=E6=AE=B5=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E9=99=90=E5=88=B6=EF=BC=8C=E4=BC=98=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=97=A5=E5=8E=86form=E8=A7=86=E5=9B=BE=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan_management/models/calendar_base.py | 13 ++++++++++--- sf_plan_management/views/plan_base_view.xml | 8 +------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sf_plan_management/models/calendar_base.py b/sf_plan_management/models/calendar_base.py index f03b8edf..5dd7df99 100644 --- a/sf_plan_management/models/calendar_base.py +++ b/sf_plan_management/models/calendar_base.py @@ -3,6 +3,8 @@ from datetime import datetime, timedelta, date from odoo import models, fields, api import re +from odoo.exceptions import ValidationError + def time_H_selection(): return [('00', '00'), ('01', '01'), ('02', '02'), ('03', '03'), ('04', '04'), ('05', '05'), @@ -37,7 +39,7 @@ class WorkLogSetting(models.Model): return num code = fields.Char(string='序号', default=_get_code, readonly=True) - name = fields.Char(string='工作日历名称', required=True) + name = fields.Char(string='工作日历名称', required=True, size=15, length=30) start_time = fields.Char(string='日开始时间', readonly=True, compute='_compute_start_time') start_time_H = fields.Selection(time_H_selection(), '时', required=True) @@ -182,7 +184,6 @@ class WorkLogSetting(models.Model): self.env['sf.work.schedule.calendar'].sudo().create({ 'name': '休息日', 'name_id': self.id, - 'calendar_code': self.code, 'date_time': single_date}) @staticmethod @@ -249,7 +250,7 @@ class WorkScheduleCalendar(models.Model): name = fields.Selection([('休息日', '休息日'), ('计划停机', '计划停机'), ('工作日', '工作日')], '日历事件名称') date_time = fields.Date('休息时间') name_id = fields.Many2one('sf.work.log.setting', '工作日历名称') - calendar_code = fields.Char('工作日历编码') + calendar_code = fields.Char('工作日历编码', readonly=True, compute='_compute_name_id') day_off_id = fields.Many2many('sf.day.off', string='休息日') scheduled_outage = fields.Char('计划停机') @@ -257,3 +258,9 @@ class WorkScheduleCalendar(models.Model): annual_rest_days = fields.Char('年休息天数', readonly=True) monthly_planned_downtime = fields.Char('月计划停机时长', readonly=True) annual_planned_downtime = fields.Char('年计划停机时长', readonly=True) + + @api.depends('name_id') + def _compute_name_id(self): + for record in self: + if record: + record.calendar_code = record.name_id.code diff --git a/sf_plan_management/views/plan_base_view.xml b/sf_plan_management/views/plan_base_view.xml index a10ccf89..04aa3400 100644 --- a/sf_plan_management/views/plan_base_view.xml +++ b/sf_plan_management/views/plan_base_view.xml @@ -70,7 +70,7 @@ - + @@ -175,12 +175,6 @@ - - - - - -