新增工序设备资源设置模型
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
|
from . import calendar_base
|
||||||
from . import base
|
from . import base
|
||||||
@@ -1,59 +1,43 @@
|
|||||||
from odoo import models, fields, api
|
from odoo import models, fields
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
class WorkLogSetting(models.Model):
|
class ProductionLine(models.Model):
|
||||||
_name = 'sf.work.log.setting'
|
_name = 'sf.production.line'
|
||||||
_description = '工作日历设置'
|
_description = '生产线'
|
||||||
|
|
||||||
input1 = fields.Char(string='Input 1')
|
name = fields.Char(string='生产线名称')
|
||||||
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)
|
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 = fields.Char(string='班次')
|
||||||
working_shift_char = fields.Char(string='班次')
|
create_time = fields.Datetime(string='新增时间', default=lambda self: fields.Datetime.now())
|
||||||
working_shift_select = fields.Selection([('0', '早班00:00-08:00'),
|
stale_dated_time = fields.Datetime(string='过期时间')
|
||||||
('1', '白班08:00-16:00'),
|
status = fields.Selection([('0', '正常'), ('1', '故障停机'), ('2', '计划停机')], string='设备状态', default='0')
|
||||||
('2', '晚班16:00-24:00'),
|
participate_in_scheduling = fields.Boolean(string='参与排程', default=True)
|
||||||
('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('输入的日结束时间不正确,请重新输入!')
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
50
sf_plan_management/models/calendar_base.py
Normal file
50
sf_plan_management/models/calendar_base.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
from odoo import models, fields, api
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
class WorkLogSetting(models.Model):
|
||||||
|
_name = 'sf.work.log.setting'
|
||||||
|
_description = '工作日历设置'
|
||||||
|
|
||||||
|
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', '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('输入的日结束时间不正确,请重新输入!')
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
access_sf_work_log_setting,sf.work.log.setting,model_sf_work_log_setting,base.group_user,1,1,1,1
|
access_sf_work_log_setting,sf.work.log.setting,model_sf_work_log_setting,base.group_user,1,1,1,1
|
||||||
|
access_sf_production_line,sf.production.line,model_sf_production_line,base.group_user,1,1,1,1
|
||||||
|
access_sf_working_procedure,sf.working.procedure,model_sf_working_procedure,base.group_user,1,1,1,1
|
||||||
|
access_sf_procedure_equipment_resource_setting,sf.procedure.equipment.resource.setting,model_sf_procedure_equipment_resource_setting,base.group_user,1,1,1,1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
@@ -18,4 +18,11 @@
|
|||||||
action="sf_work_log_setting_act"
|
action="sf_work_log_setting_act"
|
||||||
sequence="0"
|
sequence="0"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<menuitem id="menu_sf_procedure_equipment_resource_setting"
|
||||||
|
name="工序设备资源设置"
|
||||||
|
parent="menu_sf_basic_setting"
|
||||||
|
action="sf_procedure_equipment_resource_setting_act"
|
||||||
|
sequence="10"
|
||||||
|
/>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -25,19 +25,23 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form>
|
<form>
|
||||||
<sheet string-="工作日历设置">
|
<sheet string-="工作日历设置">
|
||||||
<group>
|
<group string="基础信息">
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group string="选择班次">
|
||||||
<field name="user_defined_working_shift_status"/>
|
<group>
|
||||||
<field name="working_shift" invisible="True"/>
|
<field name="user_defined_working_shift_status"/>
|
||||||
<field name="working_shift_char" attrs="{'invisible': [('user_defined_working_shift_status', '=', False)]}"/>
|
<field name="working_shift" invisible="True"/>
|
||||||
<field name="working_shift_select" attrs="{'invisible': [('user_defined_working_shift_status', '!=', False)]}"/>
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="working_shift_char" attrs="{'invisible': [('user_defined_working_shift_status', '=', False)]}"/>
|
||||||
|
<field name="working_shift_select" attrs="{'invisible': [('user_defined_working_shift_status', '!=', False)]}"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group string="工作时间">
|
||||||
<group>
|
<group>
|
||||||
<!-- <field name="start_time" widget="char" placeholder="请输入的时间为:00:00-24:00"/>-->
|
<!-- <field name="start_time" widget="char" placeholder="请输入的时间为:00:00-24:00"/>-->
|
||||||
<field name="start_time" widget="datetime"/>
|
<field name="start_time" options="{'no_date': True, 'format': 'HH:mm:ss'}"/>
|
||||||
<field name="duration"/>
|
<field name="duration"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
@@ -45,7 +49,7 @@
|
|||||||
<field name="day_off"/>
|
<field name="day_off"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group string="日历状态">
|
||||||
<field name="status"/>
|
<field name="status"/>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
@@ -58,4 +62,42 @@
|
|||||||
<field name="res_model">sf.work.log.setting</field>
|
<field name="res_model">sf.work.log.setting</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<!--========================================工序设备资源设置========================================-->
|
||||||
|
<record id="sf_procedure_equipment_resource_setting_tree" model="ir.ui.view">
|
||||||
|
<field name="name">工序设备资源设置</field>
|
||||||
|
<field name="model">sf.procedure.equipment.resource.setting</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="machine_tool_name"/>
|
||||||
|
<field name="brand"/>
|
||||||
|
<field name="model"/>
|
||||||
|
<field name="production_capacity"/>
|
||||||
|
<field name="working_calendar"/>
|
||||||
|
<field name="working_shift"/>
|
||||||
|
<field name="create_time"/>
|
||||||
|
<field name="stale_dated_time"/>
|
||||||
|
<field name="status"/>
|
||||||
|
<field name="participate_in_scheduling"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- <record id="sf_procedure_equipment_resource_setting_form" model="ir.ui.view">-->
|
||||||
|
<!-- <field name="name">工序设备资源设置</field>-->
|
||||||
|
<!-- <field name="model">sf.procedure.equipment.resource.setting</field>-->
|
||||||
|
<!-- <field name="arch" type="xml">-->
|
||||||
|
<!-- <form>-->
|
||||||
|
|
||||||
|
<!-- </form>-->
|
||||||
|
<!-- </field>-->
|
||||||
|
<!-- </record>-->
|
||||||
|
|
||||||
|
<record id="sf_procedure_equipment_resource_setting_act" model="ir.actions.act_window">
|
||||||
|
<field name="name">工序设备资源设置</field>
|
||||||
|
<field name="res_model">sf.procedure.equipment.resource.setting</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
Reference in New Issue
Block a user