对工作日历设置的name字段进行限制,优化工作日历form视图的显示
This commit is contained in:
@@ -3,6 +3,8 @@ from datetime import datetime, timedelta, date
|
|||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
def time_H_selection():
|
def time_H_selection():
|
||||||
return [('00', '00'), ('01', '01'), ('02', '02'), ('03', '03'), ('04', '04'), ('05', '05'),
|
return [('00', '00'), ('01', '01'), ('02', '02'), ('03', '03'), ('04', '04'), ('05', '05'),
|
||||||
@@ -37,7 +39,7 @@ class WorkLogSetting(models.Model):
|
|||||||
return num
|
return num
|
||||||
|
|
||||||
code = fields.Char(string='序号', default=_get_code, readonly=True)
|
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 = fields.Char(string='日开始时间', readonly=True, compute='_compute_start_time')
|
||||||
start_time_H = fields.Selection(time_H_selection(), '时', required=True)
|
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({
|
self.env['sf.work.schedule.calendar'].sudo().create({
|
||||||
'name': '休息日',
|
'name': '休息日',
|
||||||
'name_id': self.id,
|
'name_id': self.id,
|
||||||
'calendar_code': self.code,
|
|
||||||
'date_time': single_date})
|
'date_time': single_date})
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -249,7 +250,7 @@ class WorkScheduleCalendar(models.Model):
|
|||||||
name = fields.Selection([('休息日', '休息日'), ('计划停机', '计划停机'), ('工作日', '工作日')], '日历事件名称')
|
name = fields.Selection([('休息日', '休息日'), ('计划停机', '计划停机'), ('工作日', '工作日')], '日历事件名称')
|
||||||
date_time = fields.Date('休息时间')
|
date_time = fields.Date('休息时间')
|
||||||
name_id = fields.Many2one('sf.work.log.setting', '工作日历名称')
|
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='休息日')
|
day_off_id = fields.Many2many('sf.day.off', string='休息日')
|
||||||
scheduled_outage = fields.Char('计划停机')
|
scheduled_outage = fields.Char('计划停机')
|
||||||
@@ -257,3 +258,9 @@ class WorkScheduleCalendar(models.Model):
|
|||||||
annual_rest_days = fields.Char('年休息天数', readonly=True)
|
annual_rest_days = fields.Char('年休息天数', readonly=True)
|
||||||
monthly_planned_downtime = fields.Char('月计划停机时长', readonly=True)
|
monthly_planned_downtime = fields.Char('月计划停机时长', readonly=True)
|
||||||
annual_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
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
</group>
|
</group>
|
||||||
<group string="日历状态">
|
<group string="日历状态">
|
||||||
<field name="status"/>
|
<field name="status"/>
|
||||||
<field name="setting_to_calendar_ids"/>
|
<field name="setting_to_calendar_ids" invisible="True"/>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
@@ -175,12 +175,6 @@
|
|||||||
<field name="calendar_code"/>
|
<field name="calendar_code"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group string="其他">
|
|
||||||
<field name="monthly_rest_days"/>
|
|
||||||
<field name="annual_rest_days"/>
|
|
||||||
<field name="monthly_planned_downtime"/>
|
|
||||||
<field name="annual_planned_downtime"/>
|
|
||||||
</group>
|
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
Reference in New Issue
Block a user