新增计划管理模块,新增工作日历设置模块(已完成,手动输入时间部分需优化)
This commit is contained in:
1
sf_plan_management/models/__init__.py
Normal file
1
sf_plan_management/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import base
|
||||
59
sf_plan_management/models/base.py
Normal file
59
sf_plan_management/models/base.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from odoo import models, fields, api
|
||||
import re
|
||||
|
||||
|
||||
class WorkLogSetting(models.Model):
|
||||
_name = 'sf.work.log.setting'
|
||||
_description = '工作日历设置'
|
||||
|
||||
input1 = fields.Char(string='Input 1')
|
||||
input2 = fields.Char(string='Input 2')
|
||||
|
||||
name = fields.Char(string='工作日历名称')
|
||||
# start_time = fields.Char(string='日开始时间')
|
||||
start_time = fields.Datetime(string='日开始时间')
|
||||
end_time = fields.Char(string='日结束时间')
|
||||
duration = fields.Char(string='时长')
|
||||
day_off = fields.Char(string='休息日')
|
||||
|
||||
user_defined_working_shift_status = fields.Boolean(string='自定义班次', default=False)
|
||||
working_shift = fields.Char(string='班次')
|
||||
working_shift_char = fields.Char(string='班次')
|
||||
working_shift_select = fields.Selection([('0', '早班00:00-08:00'),
|
||||
('1', '白班08:00-16:00'),
|
||||
('2', '晚班16:00-24:00'),
|
||||
('3', '长白班08:00-20:00'),
|
||||
('4', '长晚班20:00-08:00')], string='班次')
|
||||
|
||||
status = fields.Boolean(string='状态', default=True)
|
||||
update_person = fields.Char(string='更新人', default=lambda self: self.env.user.name)
|
||||
update_time = fields.Datetime(string='更新时间', default=lambda self: fields.Datetime.now())
|
||||
|
||||
# @api.onchange('working_shift_char')
|
||||
# def _onchange_working_shift_char(self):
|
||||
# pattern = re.compile(r'^(([0-9]|1[0-9]|2[0-3]):[0-5][0-9])|24:00$')
|
||||
# if self.start_time and not pattern.match(self.start_time):
|
||||
# raise models.ValidationError('输入的日开始时间不正确,请重新输入!')
|
||||
|
||||
@api.onchange('working_shift_char', 'working_shift_select')
|
||||
def _onchange_working_shift(self):
|
||||
for record in self:
|
||||
if record.working_shift_select:
|
||||
record.working_shift = record.working_shift_select
|
||||
else:
|
||||
record.working_shift = record.working_shift_char
|
||||
|
||||
# @api.onchange('start_time')
|
||||
# def _onchange_start_time(self):
|
||||
# pattern = re.compile(r'^(([0-9]|1[0-9]|2[0-3]):[0-5][0-9])|24:00$')
|
||||
# if self.start_time and not pattern.match(self.start_time):
|
||||
# raise models.ValidationError('输入的日开始时间不正确,请重新输入!')
|
||||
|
||||
@api.onchange('end_time')
|
||||
def _onchange_end_time(self):
|
||||
pattern = re.compile(r'^(([0-9]|1[0-9]|2[0-3]):[0-5][0-9])|24:00$')
|
||||
for record in self:
|
||||
if record.end_time and not pattern.match(record.end_time):
|
||||
raise models.ValidationError('输入的日结束时间不正确,请重新输入!')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user