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 @@
-
-
-
-
-
-