新增工序设备资源设置模型

This commit is contained in:
yuxianghui
2023-07-05 14:47:29 +08:00
parent f685c9a3d4
commit caf367b10d
6 changed files with 147 additions and 60 deletions

View File

@@ -1,59 +1,43 @@
from odoo import models, fields, api
import re
from odoo import models, fields
class WorkLogSetting(models.Model):
_name = 'sf.work.log.setting'
_description = '工作日历设置'
class ProductionLine(models.Model):
_name = 'sf.production.line'
_description = '生产线'
input1 = fields.Char(string='Input 1')
input2 = fields.Char(string='Input 2')
name = fields.Char(string='生产线名称')
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)
class WorkingProcedure(models.Model):
_name = 'sf.working.procedure'
_description = '工序'
name = fields.Char(string='工序名称')
content = fields.Char(string='主要加工内容')
WorkingProcedure_to_ProductionLine_id = fields.Many2one('sf.production.line')
class ProcedureEquipmentResourceSetting(models.Model):
_name = 'sf.procedure.equipment.resource.setting'
_description = '工序设备资源设置'
equipment_to_working_procedure_id = fields.Many2one('sf.working.procedure', string='工序')
name = fields.Char(string='设备名称')
machine_tool_name = fields.Char(string='机台号')
brand = fields.Char(string='品牌')
model = fields.Char(string='型号')
production_capacity = fields.Char(string='产能')
working_calendar = fields.Many2one('sf.work.log.setting', string='工作日历')
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('输入的日结束时间不正确,请重新输入!')
create_time = fields.Datetime(string='新增时间', default=lambda self: fields.Datetime.now())
stale_dated_time = fields.Datetime(string='过期时间')
status = fields.Selection([('0', '正常'), ('1', '故障停机'), ('2', '计划停机')], string='设备状态', default='0')
participate_in_scheduling = fields.Boolean(string='参与排程', default=True)