From f685c9a3d45bc040cb1f31f74b92f5b718b9e6e0 Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Tue, 4 Jul 2023 17:37:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=97=A5=E5=8E=86=E8=AE=BE=E7=BD=AE=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=EF=BC=88=E5=B7=B2=E5=AE=8C=E6=88=90=EF=BC=8C=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E8=BE=93=E5=85=A5=E6=97=B6=E9=97=B4=E9=83=A8=E5=88=86?= =?UTF-8?q?=E9=9C=80=E4=BC=98=E5=8C=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan_management/__init__.py | 1 + sf_plan_management/__manifest__.py | 34 +++++++++++ sf_plan_management/models/__init__.py | 1 + sf_plan_management/models/base.py | 59 ++++++++++++++++++ .../security/ir.model.access.csv | 8 +++ sf_plan_management/views/menu_view.xml | 21 +++++++ sf_plan_management/views/paln_base_view.xml | 61 +++++++++++++++++++ 7 files changed, 185 insertions(+) create mode 100644 sf_plan_management/__init__.py create mode 100644 sf_plan_management/__manifest__.py create mode 100644 sf_plan_management/models/__init__.py create mode 100644 sf_plan_management/models/base.py create mode 100644 sf_plan_management/security/ir.model.access.csv create mode 100644 sf_plan_management/views/menu_view.xml create mode 100644 sf_plan_management/views/paln_base_view.xml diff --git a/sf_plan_management/__init__.py b/sf_plan_management/__init__.py new file mode 100644 index 00000000..9a7e03ed --- /dev/null +++ b/sf_plan_management/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/sf_plan_management/__manifest__.py b/sf_plan_management/__manifest__.py new file mode 100644 index 00000000..9a8af0cd --- /dev/null +++ b/sf_plan_management/__manifest__.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +{ + 'name': '机企猫智能工厂 计划管理', + 'version': '1.0', + 'summary': '智能工厂计划管理', + 'sequence': 1, + 'description': """ +在本模块,定义了计划管理的清单和原型 + """, + 'category': 'sf', + 'website': 'https://www.sf.jikimo.com', + 'depends': [], + 'data': [ + 'security/ir.model.access.csv', + 'views/paln_base_view.xml', + 'views/menu_view.xml' + ], + 'demo': [ + ], + 'assets': { + + 'web.assets_qweb': [ + ], + 'web.assets_backend':[ + ] + + + }, + 'license': 'LGPL-3', + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/sf_plan_management/models/__init__.py b/sf_plan_management/models/__init__.py new file mode 100644 index 00000000..cf50d1cc --- /dev/null +++ b/sf_plan_management/models/__init__.py @@ -0,0 +1 @@ +from . import base \ No newline at end of file diff --git a/sf_plan_management/models/base.py b/sf_plan_management/models/base.py new file mode 100644 index 00000000..242a67bc --- /dev/null +++ b/sf_plan_management/models/base.py @@ -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('输入的日结束时间不正确,请重新输入!') + + diff --git a/sf_plan_management/security/ir.model.access.csv b/sf_plan_management/security/ir.model.access.csv new file mode 100644 index 00000000..d2e97991 --- /dev/null +++ b/sf_plan_management/security/ir.model.access.csv @@ -0,0 +1,8 @@ +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 + + + + + + diff --git a/sf_plan_management/views/menu_view.xml b/sf_plan_management/views/menu_view.xml new file mode 100644 index 00000000..3c1345f3 --- /dev/null +++ b/sf_plan_management/views/menu_view.xml @@ -0,0 +1,21 @@ + + + + + + + + \ No newline at end of file diff --git a/sf_plan_management/views/paln_base_view.xml b/sf_plan_management/views/paln_base_view.xml new file mode 100644 index 00000000..0d8ea30b --- /dev/null +++ b/sf_plan_management/views/paln_base_view.xml @@ -0,0 +1,61 @@ + + + + + 工作日历设置 + sf.work.log.setting + + + + + + + + + + + + + + + + + 工作日历设置 + sf.work.log.setting + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + 工作日历设置 + sf.work.log.setting + tree,form + +
\ No newline at end of file From caf367b10d51c526926689cfb403128fb82688c2 Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Wed, 5 Jul 2023 14:47:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B7=A5=E5=BA=8F?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=B5=84=E6=BA=90=E8=AE=BE=E7=BD=AE=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan_management/models/__init__.py | 1 + sf_plan_management/models/base.py | 86 ++++++++----------- sf_plan_management/models/calendar_base.py | 50 +++++++++++ .../security/ir.model.access.csv | 3 + sf_plan_management/views/menu_view.xml | 7 ++ sf_plan_management/views/paln_base_view.xml | 60 +++++++++++-- 6 files changed, 147 insertions(+), 60 deletions(-) create mode 100644 sf_plan_management/models/calendar_base.py diff --git a/sf_plan_management/models/__init__.py b/sf_plan_management/models/__init__.py index cf50d1cc..9a2c9000 100644 --- a/sf_plan_management/models/__init__.py +++ b/sf_plan_management/models/__init__.py @@ -1 +1,2 @@ +from . import calendar_base from . import base \ No newline at end of file diff --git a/sf_plan_management/models/base.py b/sf_plan_management/models/base.py index 242a67bc..76b1c0fc 100644 --- a/sf_plan_management/models/base.py +++ b/sf_plan_management/models/base.py @@ -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) + + + + + diff --git a/sf_plan_management/models/calendar_base.py b/sf_plan_management/models/calendar_base.py new file mode 100644 index 00000000..dc22b92f --- /dev/null +++ b/sf_plan_management/models/calendar_base.py @@ -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('输入的日结束时间不正确,请重新输入!') + + diff --git a/sf_plan_management/security/ir.model.access.csv b/sf_plan_management/security/ir.model.access.csv index d2e97991..1103d658 100644 --- a/sf_plan_management/security/ir.model.access.csv +++ b/sf_plan_management/security/ir.model.access.csv @@ -1,5 +1,8 @@ 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_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 diff --git a/sf_plan_management/views/menu_view.xml b/sf_plan_management/views/menu_view.xml index 3c1345f3..1641947c 100644 --- a/sf_plan_management/views/menu_view.xml +++ b/sf_plan_management/views/menu_view.xml @@ -18,4 +18,11 @@ action="sf_work_log_setting_act" sequence="0" /> + + \ No newline at end of file diff --git a/sf_plan_management/views/paln_base_view.xml b/sf_plan_management/views/paln_base_view.xml index 0d8ea30b..b8b63cb3 100644 --- a/sf_plan_management/views/paln_base_view.xml +++ b/sf_plan_management/views/paln_base_view.xml @@ -25,19 +25,23 @@
- + - - - - - + + + + + + + + + - + - + @@ -45,7 +49,7 @@ - + @@ -58,4 +62,42 @@ sf.work.log.setting tree,form + + + + + 工序设备资源设置 + sf.procedure.equipment.resource.setting + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 工序设备资源设置 + sf.procedure.equipment.resource.setting + tree,form + \ No newline at end of file