新增班次对象,新增工作日对象,修改了工作日历设置的班次、工作日字段类型;新增工作日历表对象
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
'data': [
|
||||
'security/group_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'views/production_line_base.py',
|
||||
'views/production_line_view.xml',
|
||||
'views/maintenance_views.xml',
|
||||
'views/maintenance_logs_views.xml',
|
||||
'views/equipment_maintenance_standards_views.xml',
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_sf_production_line"
|
||||
parent="menu_sf_base"
|
||||
parent="sf_base.menu_sf_base"
|
||||
name="生产线"
|
||||
sequence="20"
|
||||
action="sf_production_line_act"/>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
# 'security/ir.model.access.csv',
|
||||
'views/paln_base_view.xml',
|
||||
'views/plan_base_view.xml',
|
||||
'views/menu_view.xml',
|
||||
],
|
||||
'demo': [
|
||||
|
||||
@@ -19,7 +19,7 @@ class ProcedureEquipmentResourceSetting(models.Model):
|
||||
working_procedure = fields.Char(string='工序', readonly=True)
|
||||
production_capacity = fields.Float(string='产能', required=True, digits=(4, 1))
|
||||
working_calendar_id = fields.Many2one('sf.work.log.setting', string='工作日历')
|
||||
working_shift = fields.Char(string='班次', readonly=True, compute='_onchange_working_calendar_id')
|
||||
working_shift_id = fields.Many2many('sf.working.shift', string='班次', readonly=True, compute='_onchange_working_calendar_id')
|
||||
create_time = fields.Datetime(string='新增时间', default=lambda self: fields.Datetime.now(), readonly=True)
|
||||
status = fields.Selection([('正常', '正常'), ('1', '故障停机'), ('2', '计划停机')],
|
||||
string='设备状态',
|
||||
@@ -49,7 +49,7 @@ class ProcedureEquipmentResourceSetting(models.Model):
|
||||
@api.depends('working_calendar_id')
|
||||
def _onchange_working_calendar_id(self):
|
||||
for record in self:
|
||||
record.working_shift = record.working_calendar_id.working_shift
|
||||
record.working_shift_id = record.working_calendar_id.working_shift_id
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -45,24 +45,9 @@ class WorkLogSetting(models.Model):
|
||||
end_time_M = fields.Selection(time_M_or_S_selection(), '分', required=True)
|
||||
|
||||
duration = fields.Char(string='时长', readonly=True, compute='_compute_duration')
|
||||
day_off = fields.Char(string='休息日', required=True)
|
||||
day_off_id = fields.Many2many('sf.day.off', string='休息日', required=True)
|
||||
|
||||
user_defined_working_shift_status = fields.Boolean(string='自定义班次', default=False)
|
||||
working_shift = fields.Char(string='班次')
|
||||
working_shift_char = fields.Char(string='班次', readonly=True, compute='_compute_working_shift_time')
|
||||
working_shift_select = fields.Selection([('早班00:00-08:00', '早班00:00-08:00'),
|
||||
('白班08:00-16:00', '白班08:00-16:00'),
|
||||
('晚班16:00-24:00', '晚班16:00-24:00'),
|
||||
('长白班08:00-20:00', '长白班08:00-20:00'),
|
||||
('长晚班20:00-08:00', '长晚班20:00-08:00')], string='班次')
|
||||
working_shift_start_time_H = fields.Selection(time_H_selection(), '班次开始时间:时',
|
||||
attr={'required': [('user_defined_working_shift_status', '=', 'True')]})
|
||||
working_shift_start_time_M = fields.Selection(time_M_or_S_selection(), '分',
|
||||
attr={'required': [('user_defined_working_shift_status', '=', 'True')]})
|
||||
working_shift_end_time_H = fields.Selection(time_H_selection(), '班次结束时间:时',
|
||||
attr={'required': [('user_defined_working_shift_status', '=', 'True')]})
|
||||
working_shift_end_time_M = fields.Selection(time_M_or_S_selection(), '分',
|
||||
attr={'required': [('user_defined_working_shift_status', '=', 'True')]})
|
||||
working_shift_id = fields.Many2many('sf.working.shift', string='班次')
|
||||
|
||||
status = fields.Boolean(string='状态', default=True)
|
||||
update_person = fields.Char(string='更新人', default=lambda self: self.env.user.name)
|
||||
@@ -86,27 +71,7 @@ class WorkLogSetting(models.Model):
|
||||
for record in self:
|
||||
record.end_time = f"{record.end_time_H}:{record.end_time_M}:00"
|
||||
|
||||
@api.onchange('working_shift_char', 'working_shift_select')
|
||||
def _onchange_working_shift(self):
|
||||
"""
|
||||
对班次是否手动输入是进行不同的展示
|
||||
:return:
|
||||
"""
|
||||
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.depends(
|
||||
'working_shift_start_time_H', 'working_shift_start_time_M',
|
||||
'working_shift_end_time_H', 'working_shift_end_time_M')
|
||||
def _compute_working_shift_time(self):
|
||||
start_time = f"{self.working_shift_start_time_H}:{self.working_shift_start_time_M}:00"
|
||||
end_time = f"{self.working_shift_end_time_H}:{self.working_shift_end_time_M}:00"
|
||||
self.working_shift_char = f"自定义班次{start_time}-{end_time}"
|
||||
|
||||
@api.depends('start_time_H', 'start_time_M', 'end_time_H', 'end_time_M')
|
||||
@api.depends('start_time_H', 'start_time_M', 'end_time_H', 'end_time_M')
|
||||
def _compute_duration(self):
|
||||
"""
|
||||
根据日开始时间和日结束时间计算每日工作时长
|
||||
@@ -119,6 +84,75 @@ class WorkLogSetting(models.Model):
|
||||
end_m = float(record.end_time_M)
|
||||
# 日开始时间小于日结束时间
|
||||
if st_h < end_h:
|
||||
record.duration = str(round(end_h-st_h+(end_m-st_m)/60, 2))
|
||||
record.duration = str(round(end_h - st_h + (end_m - st_m) / 60, 2))
|
||||
else:
|
||||
record.duration = str(round(end_h-st_h+(end_m-st_m)/60+24, 2))
|
||||
record.duration = str(round(end_h - st_h + (end_m - st_m) / 60 + 24, 2))
|
||||
|
||||
# @api.model
|
||||
# def create(self, vals_list):
|
||||
# """
|
||||
# 创建新工作日历设置记录时,同时根据所选的休息日新建工作日历的休息日记录
|
||||
# :param vals_list:
|
||||
# :return:
|
||||
# """
|
||||
#
|
||||
#
|
||||
# return super(WorkLogSetting, self).create(vals_list)
|
||||
|
||||
|
||||
class WorkingShift(models.Model):
|
||||
_name = 'sf.working.shift'
|
||||
_description = '班次'
|
||||
|
||||
def _get_code(self):
|
||||
"""
|
||||
自动生成编码
|
||||
:return:
|
||||
"""
|
||||
fixture_material = self.env['sf.working.shift'].sudo().search(
|
||||
[('code', '!=', '')],
|
||||
limit=1,
|
||||
order="id desc")
|
||||
if not fixture_material:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
m = int(fixture_material.code) + 1
|
||||
num = "%03d" % m
|
||||
return num
|
||||
|
||||
code = fields.Char('编码', default=_get_code, readonly=True)
|
||||
name = fields.Char('名称', required=True)
|
||||
start_time = fields.Datetime('班次开始时间')
|
||||
end_time = fields.Datetime('班次结束时间')
|
||||
remark = fields.Char('备注')
|
||||
|
||||
|
||||
class DayOff(models.Model):
|
||||
_name = 'sf.day.off'
|
||||
_description = '休息日'
|
||||
|
||||
name = fields.Selection([
|
||||
('周一', '周一'),
|
||||
('周二', '周二'),
|
||||
('周三', '周三'),
|
||||
('周四', '周四'),
|
||||
('周五', '周五'),
|
||||
('周六', '周六'),
|
||||
('周日', '周日')], '休息日名称')
|
||||
|
||||
|
||||
class WorkScheduleCalendar(models.Model):
|
||||
_name = 'sf.work.schedule.calendar'
|
||||
_description = '工作安排日历'
|
||||
|
||||
name_id = fields.Many2one('sf.work.log.setting', '工作日历名称')
|
||||
day_off_id = fields.Many2many('sf.day.off', string='休息日')
|
||||
scheduled_outage = fields.Char('计划停机')
|
||||
monthly_rest_days = fields.Char('月休息天数', readonly=True)
|
||||
annual_rest_days = fields.Char('年休息天数', readonly=True)
|
||||
monthly_planned_downtime = fields.Char('月计划停机时长', readonly=True)
|
||||
annual_planned_downtime = fields.Char('年计划停机时长', readonly=True)
|
||||
|
||||
name = fields.Selection([('休息日', '休息日'),('计划停机', '计划停机')], '名称')
|
||||
date_time = fields.Datetime('休息时间')
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@ 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_procedure_equipment_resource_setting,sf.procedure.equipment.resource.setting,model_sf_procedure_equipment_resource_setting,base.group_user,1,1,1,1
|
||||
|
||||
access_sf_day_off,sf.day.off,model_sf_day_off,base.group_user,1,1,1,1
|
||||
access_sf_working_shift,sf.working.shift,model_sf_working_shift,base.group_user,1,1,1,1
|
||||
access_sf_work_schedule_calendar,sf.work.schedule.calendar,model_sf_work_schedule_calendar,base.group_user,1,1,1,1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -25,4 +25,25 @@
|
||||
action="sf_procedure_equipment_resource_setting_act"
|
||||
sequence="10"
|
||||
/>
|
||||
|
||||
<menuitem id="menu_sf_working_shift"
|
||||
name="班次"
|
||||
parent="menu_sf_basic_setting"
|
||||
action="sf_working_shift_act"
|
||||
sequence="12"
|
||||
/>
|
||||
|
||||
<menuitem id="menu_sf_day_off"
|
||||
name="休息日"
|
||||
parent="menu_sf_basic_setting"
|
||||
action="sf_day_off_act"
|
||||
sequence="15"
|
||||
/>
|
||||
|
||||
<menuitem id="menu_sf_work_schedule_calendar"
|
||||
name="工作安排日历"
|
||||
parent="menu_sf_basic_setting"
|
||||
action="sf_work_schedule_calendar_act"
|
||||
sequence="15"
|
||||
/>
|
||||
</odoo>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<!--========================================工作日历设置========================================-->
|
||||
<!--================================================工作日历设置================================================-->
|
||||
<record id="sf_work_log_setting_tree" model="ir.ui.view">
|
||||
<field name="name">工作日历设置</field>
|
||||
<field name="model">sf.work.log.setting</field>
|
||||
@@ -11,8 +11,8 @@
|
||||
<field name="start_time"/>
|
||||
<field name="end_time"/>
|
||||
<field name="duration"/>
|
||||
<field name="day_off"/>
|
||||
<field name="working_shift"/>
|
||||
<field name="day_off_id" widget="many2many_tags"/>
|
||||
<field name="working_shift_id" widget="many2many_tags"/>
|
||||
<field name="status"/>
|
||||
<field name="update_person"/>
|
||||
<field name="update_time"/>
|
||||
@@ -35,29 +35,7 @@
|
||||
</group>
|
||||
</group>
|
||||
<group string="选择班次">
|
||||
<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>
|
||||
<field name="user_defined_working_shift_status"/>
|
||||
<field name="working_shift" invisible="True"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group>
|
||||
<group>
|
||||
<field name="working_shift_start_time_H" attrs="{'invisible': [('user_defined_working_shift_status', '=', False)]}"/>
|
||||
<field name="working_shift_end_time_H" attrs="{'invisible': [('user_defined_working_shift_status', '=', False)]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="working_shift_start_time_M" attrs="{'invisible': [('user_defined_working_shift_status', '=', False)]}"/>
|
||||
<field name="working_shift_end_time_M" attrs="{'invisible': [('user_defined_working_shift_status', '=', False)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<field name="working_shift_id"/>
|
||||
</group>
|
||||
<group string="工作时间">
|
||||
<group>
|
||||
@@ -80,9 +58,9 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="duration"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="day_off"/>
|
||||
<field name="day_off_id"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True, 'no_quick_create': True}"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="日历状态">
|
||||
@@ -100,7 +78,137 @@
|
||||
</record>
|
||||
|
||||
|
||||
<!--========================================产线设备资源设置========================================-->
|
||||
<!--================================================休息日================================================-->
|
||||
<record id="sf_day_off_tree" model="ir.ui.view">
|
||||
<field name="name">休息日</field>
|
||||
<field name="model">sf.day.off</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_day_off_act" model="ir.actions.act_window">
|
||||
<field name="name">休息日</field>
|
||||
<field name="res_model">sf.day.off</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!--================================================班次================================================-->
|
||||
<record id="sf_working_shift_tree" model="ir.ui.view">
|
||||
<field name="name">班次</field>
|
||||
<field name="model">sf.working.shift</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="start_time"/>
|
||||
<field name="end_time"/>
|
||||
<field name="remark"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_working_shift_form" model="ir.ui.view">
|
||||
<field name="name">班次</field>
|
||||
<field name="model">sf.working.shift</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="start_time"/>
|
||||
<field name="end_time"/>
|
||||
<field name="remark"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="code"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_working_shift_act" model="ir.actions.act_window">
|
||||
<field name="name">班次</field>
|
||||
<field name="res_model">sf.working.shift</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!--================================================工作安排日历================================================-->
|
||||
<record id="sf_work_schedule_calendar_tree" model="ir.ui.view">
|
||||
<field name="name">工作安排日历</field>
|
||||
<field name="model">sf.work.schedule.calendar</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="name_id" invisible="True"/>
|
||||
<field name="name"/>
|
||||
<field name="date_time"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_work_schedule_calendar_form" model="ir.ui.view">
|
||||
<field name="name">工作安排日历</field>
|
||||
<field name="model">sf.work.schedule.calendar</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<group string="日历基本信息">
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="date_time"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="name_id"/>
|
||||
</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>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_work_schedule_calendar_search" model="ir.ui.view">
|
||||
<field name="name">工作安排日历</field>
|
||||
<field name="model">sf.work.schedule.calendar</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<searchpanel>
|
||||
<field name="name_id" icon="fa-building" enable_counters="1"/>
|
||||
</searchpanel>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_work_schedule_calendar_calendar" model="ir.ui.view">
|
||||
<field name="name">工作安排日历</field>
|
||||
<field name="model">sf.work.schedule.calendar</field>
|
||||
<field name="arch" type="xml">
|
||||
<calendar string="工作日历" mode="year" date_start="date_time">
|
||||
<field name="name"/>
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_work_schedule_calendar_act" model="ir.actions.act_window">
|
||||
<field name="name">工作安排日历</field>
|
||||
<field name="res_model">sf.work.schedule.calendar</field>
|
||||
<field name="view_mode">calendar,search,tree,form</field>
|
||||
</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>
|
||||
@@ -114,7 +222,7 @@
|
||||
<field name="working_procedure"/>
|
||||
<field name="production_capacity"/>
|
||||
<field name="working_calendar_id"/>
|
||||
<field name="working_shift"/>
|
||||
<field name="working_shift_id" widget="many2many_tags"/>
|
||||
<field name="create_time"/>
|
||||
<field name="status"/>
|
||||
<field name="participate_in_scheduling"/>
|
||||
@@ -161,7 +269,7 @@
|
||||
<field name="create_time"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="working_shift"/>
|
||||
<field name="working_shift_id" widget="many2many_tags"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
@@ -182,7 +290,7 @@
|
||||
<field name="working_procedure"/>
|
||||
<field name="production_capacity"/>
|
||||
<field name="working_calendar_id"/>
|
||||
<field name="working_shift"/>
|
||||
<field name="working_shift_id"/>
|
||||
<field name="create_time"/>
|
||||
<field name="status"/>
|
||||
<field name="participate_in_scheduling"/>
|
||||
Reference in New Issue
Block a user