From 6dfced854166bf181ad3db9f2a8b6cfb4335e2a8 Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Mon, 10 Jul 2023 17:26:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=8F=AD=E6=AC=A1?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=97=A5=E5=AF=B9=E8=B1=A1=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=97=A5=E5=8E=86=E8=AE=BE=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E7=8F=AD=E6=AC=A1=E3=80=81=E5=B7=A5=E4=BD=9C=E6=97=A5=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=B1=BB=E5=9E=8B=EF=BC=9B=E6=96=B0=E5=A2=9E=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=97=A5=E5=8E=86=E8=A1=A8=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_maintenance/__manifest__.py | 2 +- sf_maintenance/views/production_line_view.xml | 2 +- sf_plan_management/__manifest__.py | 2 +- sf_plan_management/models/base.py | 4 +- sf_plan_management/models/calendar_base.py | 114 ++++++++---- .../security/ir.model.access.csv | 4 + sf_plan_management/views/menu_view.xml | 21 +++ ...{paln_base_view.xml => plan_base_view.xml} | 174 ++++++++++++++---- 8 files changed, 245 insertions(+), 78 deletions(-) rename sf_plan_management/views/{paln_base_view.xml => plan_base_view.xml} (56%) diff --git a/sf_maintenance/__manifest__.py b/sf_maintenance/__manifest__.py index 6e644ebc..17b1e541 100644 --- a/sf_maintenance/__manifest__.py +++ b/sf_maintenance/__manifest__.py @@ -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', diff --git a/sf_maintenance/views/production_line_view.xml b/sf_maintenance/views/production_line_view.xml index 0772d116..b9fd459f 100644 --- a/sf_maintenance/views/production_line_view.xml +++ b/sf_maintenance/views/production_line_view.xml @@ -74,7 +74,7 @@ diff --git a/sf_plan_management/__manifest__.py b/sf_plan_management/__manifest__.py index 44be0987..fa2c7ffb 100644 --- a/sf_plan_management/__manifest__.py +++ b/sf_plan_management/__manifest__.py @@ -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': [ diff --git a/sf_plan_management/models/base.py b/sf_plan_management/models/base.py index 1a8d1e27..57df9566 100644 --- a/sf_plan_management/models/base.py +++ b/sf_plan_management/models/base.py @@ -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 diff --git a/sf_plan_management/models/calendar_base.py b/sf_plan_management/models/calendar_base.py index 0bc1ba56..5d75aea2 100644 --- a/sf_plan_management/models/calendar_base.py +++ b/sf_plan_management/models/calendar_base.py @@ -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('休息时间') + diff --git a/sf_plan_management/security/ir.model.access.csv b/sf_plan_management/security/ir.model.access.csv index 98cf2ae7..45b4c99b 100644 --- a/sf_plan_management/security/ir.model.access.csv +++ b/sf_plan_management/security/ir.model.access.csv @@ -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 + diff --git a/sf_plan_management/views/menu_view.xml b/sf_plan_management/views/menu_view.xml index 2bf4569d..926b7ea7 100644 --- a/sf_plan_management/views/menu_view.xml +++ b/sf_plan_management/views/menu_view.xml @@ -25,4 +25,25 @@ action="sf_procedure_equipment_resource_setting_act" sequence="10" /> + + + + + + \ No newline at end of file diff --git a/sf_plan_management/views/paln_base_view.xml b/sf_plan_management/views/plan_base_view.xml similarity index 56% rename from sf_plan_management/views/paln_base_view.xml rename to sf_plan_management/views/plan_base_view.xml index 645aa45d..bc4cd2a4 100644 --- a/sf_plan_management/views/paln_base_view.xml +++ b/sf_plan_management/views/plan_base_view.xml @@ -1,6 +1,6 @@ - + 工作日历设置 sf.work.log.setting @@ -11,8 +11,8 @@ - - + + @@ -35,29 +35,7 @@ - - - - - - - - - - - - - - - - - - - - - - - + @@ -80,9 +58,9 @@ - - - + @@ -100,7 +78,137 @@ - + + + 休息日 + sf.day.off + + + + + + + + + 休息日 + sf.day.off + tree,form + + + + + + 班次 + sf.working.shift + + + + + + + + + + + + + 班次 + sf.working.shift + +
+ + + + + + + + + + + + + +
+
+
+ + + 班次 + sf.working.shift + tree,form + + + + + + 工作安排日历 + sf.work.schedule.calendar + + + + + + + + + + + 工作安排日历 + sf.work.schedule.calendar + +
+ + + + + + + + + + + + + + + + + +
+
+
+ + + 工作安排日历 + sf.work.schedule.calendar + + + + + + + + + + + 工作安排日历 + sf.work.schedule.calendar + + + + + + + + + 工作安排日历 + sf.work.schedule.calendar + calendar,search,tree,form + + + + 产线设备资源设置 sf.procedure.equipment.resource.setting @@ -114,7 +222,7 @@ - + @@ -161,7 +269,7 @@ - + @@ -182,7 +290,7 @@ - + From ef7d9c22d40decf96e7805f0c4ab2dbb8811d55b Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Tue, 11 Jul 2023 17:40:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=97=A5=E5=8E=86=E8=AE=BE=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=97=A5=E5=AD=97=E6=AE=B5=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=97=A5=E5=8E=86=E7=9A=84=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan_management/models/calendar_base.py | 83 ++++++++++++++++----- sf_plan_management/views/plan_base_view.xml | 8 +- 2 files changed, 68 insertions(+), 23 deletions(-) diff --git a/sf_plan_management/models/calendar_base.py b/sf_plan_management/models/calendar_base.py index 5d75aea2..3cd41a1e 100644 --- a/sf_plan_management/models/calendar_base.py +++ b/sf_plan_management/models/calendar_base.py @@ -1,3 +1,5 @@ +from datetime import datetime, timedelta + from odoo import models, fields, api import re @@ -88,16 +90,49 @@ class WorkLogSetting(models.Model): else: 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) + @api.onchange('day_off_id') + def _onchange_day_off_id(self): + # 先删除之前创建的工作日历事件记录 + self.env['sf.work.schedule.calendar'].search([ + ('calendar_code', '=', self.code), ('name_id', '=', self.name)]).unlink() + + # 获取当年的一月一号的日期 + year = fields.Datetime.now().year # 2023 + first_day = datetime(year, 1, 1).date() # 2023-01-01 + day_of_week = first_day.strftime("%A") # 星期日 + + # 根据day_of_week,将其设置为起始0,循环周一到周日,按循环顺序设置为0-6 + # 列:{'星期日': 0, '星期一': 1, '星期二': 2, '星期三': 3, '星期四': 4, '星期五': 5, '星期六': 6} + desc = {} + desc_weekdays = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'] + status = False + ints = 0 + while len(desc) < 7: + if len(desc) != 0: + for week in desc_weekdays: + if len(desc) < 7: + desc.update({week: ints}) + ints += 1 + else: + for week in desc_weekdays: + if status: + desc.update({week: ints}) + ints += 1 + if day_of_week == week: + desc.update({week: ints}) + status = True + ints += 1 + + # 创建工作日历的休息日事件 + # day_off_ids = self.day_off_id.mapped('name') + # for week in day_off_ids: + # num = desc[week] + # while num <= 30: + # target_date = first_day + timedelta(days=num) + # self.env['sf.work.schedule.calendar'].create({'name': '休息日', + # 'name_id': self.name.id, + # 'date_time': target_date}) + # num += 7 class WorkingShift(models.Model): @@ -132,20 +167,24 @@ class DayOff(models.Model): _description = '休息日' name = fields.Selection([ - ('周一', '周一'), - ('周二', '周二'), - ('周三', '周三'), - ('周四', '周四'), - ('周五', '周五'), - ('周六', '周六'), - ('周日', '周日')], '休息日名称') + ('星期一', '星期一'), + ('星期二', '星期二'), + ('星期三', '星期三'), + ('星期四', '星期四'), + ('星期五', '星期五'), + ('星期六', '星期六'), + ('星期日', '星期日')], '休息日名称') class WorkScheduleCalendar(models.Model): _name = 'sf.work.schedule.calendar' - _description = '工作安排日历' + _description = '工作日历' + + name = fields.Selection([('休息日', '休息日'), ('计划停机', '计划停机')], '日历事件名称') + date_time = fields.Date('休息时间') name_id = fields.Many2one('sf.work.log.setting', '工作日历名称') + calendar_code = fields.Char('工作日历编码') day_off_id = fields.Many2many('sf.day.off', string='休息日') scheduled_outage = fields.Char('计划停机') monthly_rest_days = fields.Char('月休息天数', readonly=True) @@ -153,6 +192,10 @@ class WorkScheduleCalendar(models.Model): monthly_planned_downtime = fields.Char('月计划停机时长', readonly=True) annual_planned_downtime = fields.Char('年计划停机时长', readonly=True) - name = fields.Selection([('休息日', '休息日'),('计划停机', '计划停机')], '名称') - date_time = fields.Datetime('休息时间') + @api.onchange('name_id') + def _onchange_name_id(self): + for record in self: + record.calendar_code = record.name_id.code + + diff --git a/sf_plan_management/views/plan_base_view.xml b/sf_plan_management/views/plan_base_view.xml index bc4cd2a4..c07a1b85 100644 --- a/sf_plan_management/views/plan_base_view.xml +++ b/sf_plan_management/views/plan_base_view.xml @@ -16,6 +16,7 @@ + @@ -140,9 +141,9 @@ - + - 工作安排日历 + 工作日历 sf.work.schedule.calendar @@ -154,7 +155,7 @@ - 工作安排日历 + 工作日历 sf.work.schedule.calendar
@@ -166,6 +167,7 @@ + From 81842dc5ecb3362b753c5029cc15c7d1d44b5bfb Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Thu, 13 Jul 2023 16:05:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=B0=86=E7=94=9F=E4=BA=A7=E7=BA=BF?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E4=BB=8E=E8=AE=BE=E5=A4=87=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=90=AC=E7=A7=BB=E5=88=B0=E4=BA=86=E5=88=B6=E9=80=A0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=B7=A5=E4=BD=9C=E6=97=A5?= =?UTF-8?q?=E5=8E=86=E8=AE=BE=E7=BD=AE=E4=BF=AE=E6=94=B9=E4=BC=91=E6=81=AF?= =?UTF-8?q?=E6=97=A5=E5=AD=97=E6=AE=B5=E5=88=99=E5=B7=A5=E4=BD=9C=E6=97=A5?= =?UTF-8?q?=E5=8E=86=E5=88=9B=E5=BB=BA=E6=96=B0=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_maintenance/__manifest__.py | 1 - sf_maintenance/models/__init__.py | 1 - sf_maintenance/security/ir.model.access.csv | 2 +- sf_manufacturing/__manifest__.py | 1 + sf_manufacturing/models/__init__.py | 1 + .../models/production_line_base.py | 0 sf_manufacturing/security/ir.model.access.csv | 2 +- .../views/production_line_view.xml | 0 sf_plan_management/__manifest__.py | 2 +- sf_plan_management/models/calendar_base.py | 39 +++++++++++-------- sf_plan_management/views/menu_view.xml | 2 +- sf_plan_management/views/plan_base_view.xml | 7 ++-- 12 files changed, 32 insertions(+), 26 deletions(-) rename {sf_maintenance => sf_manufacturing}/models/production_line_base.py (100%) rename {sf_maintenance => sf_manufacturing}/views/production_line_view.xml (100%) diff --git a/sf_maintenance/__manifest__.py b/sf_maintenance/__manifest__.py index 17b1e541..529c62fc 100644 --- a/sf_maintenance/__manifest__.py +++ b/sf_maintenance/__manifest__.py @@ -12,7 +12,6 @@ 'data': [ 'security/group_security.xml', 'security/ir.model.access.csv', - 'views/production_line_view.xml', 'views/maintenance_views.xml', 'views/maintenance_logs_views.xml', 'views/equipment_maintenance_standards_views.xml', diff --git a/sf_maintenance/models/__init__.py b/sf_maintenance/models/__init__.py index 98f9d12c..0e06b132 100644 --- a/sf_maintenance/models/__init__.py +++ b/sf_maintenance/models/__init__.py @@ -3,4 +3,3 @@ from . import sf_maintenance from . import sf_maintenance_logs from . import sf_equipment_maintenance_standards from . import sf_maintenance_requests -from . import production_line_base diff --git a/sf_maintenance/security/ir.model.access.csv b/sf_maintenance/security/ir.model.access.csv index 809ed5b6..52c0ab72 100644 --- a/sf_maintenance/security/ir.model.access.csv +++ b/sf_maintenance/security/ir.model.access.csv @@ -4,6 +4,6 @@ access_sf_maintenance_logs,sf_maintenance_logs,model_sf_maintenance_logs,base.gr access_maintenance_equipment,maintenance_equipment,model_maintenance_equipment,base.group_user,1,1,1,1 access_maintenance_standards,maintenance_standards,model_maintenance_standards,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 + diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 5e61bb27..adde17a8 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -20,6 +20,7 @@ 'views/mrp_routing_workcenter_view.xml', 'views/mrp_workcenter_views.xml', 'views/mrp_workorder_view.xml', + 'views/production_line_view.xml', 'views/tray_view.xml', 'views/model_type_view.xml', diff --git a/sf_manufacturing/models/__init__.py b/sf_manufacturing/models/__init__.py index 055eece0..2d7d2f1e 100644 --- a/sf_manufacturing/models/__init__.py +++ b/sf_manufacturing/models/__init__.py @@ -8,6 +8,7 @@ from . import mrp_maintenance from . import mrp_routing_workcenter from . import stock from . import res_user +from . import production_line_base diff --git a/sf_maintenance/models/production_line_base.py b/sf_manufacturing/models/production_line_base.py similarity index 100% rename from sf_maintenance/models/production_line_base.py rename to sf_manufacturing/models/production_line_base.py diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index bc24436c..e0a78bb6 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -5,7 +5,7 @@ access_sf_product_model_type_routing_sort,sf_product_model_type_routing_sort,mod access_sf_embryo_model_type_routing_sort,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,base.group_user,1,1,1,1 access_sf_surface_technics_model_type_routing_sort,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,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 diff --git a/sf_maintenance/views/production_line_view.xml b/sf_manufacturing/views/production_line_view.xml similarity index 100% rename from sf_maintenance/views/production_line_view.xml rename to sf_manufacturing/views/production_line_view.xml diff --git a/sf_plan_management/__manifest__.py b/sf_plan_management/__manifest__.py index fa2c7ffb..d4ec406b 100644 --- a/sf_plan_management/__manifest__.py +++ b/sf_plan_management/__manifest__.py @@ -10,7 +10,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sf_maintenance'], + 'depends': ['sf_manufacturing'], 'data': [ 'security/ir.model.access.csv', # 'security/ir.model.access.csv', diff --git a/sf_plan_management/models/calendar_base.py b/sf_plan_management/models/calendar_base.py index 3cd41a1e..6176bde3 100644 --- a/sf_plan_management/models/calendar_base.py +++ b/sf_plan_management/models/calendar_base.py @@ -55,6 +55,13 @@ class WorkLogSetting(models.Model): update_person = fields.Char(string='更新人', default=lambda self: self.env.user.name) update_time = fields.Datetime(string='更新时间', default=lambda self: fields.Datetime.now()) + setting_to_calendar_ids = fields.One2many('sf.work.schedule.calendar', 'name_id', '工作日历') + + # @api.model + # def create(self, vals): + # vals['setting_to_calendar_ids'] = [(4, child.id)] + # return super(WorkLogSetting, self).create(vals) + @api.depends('start_time_H', 'start_time_M') def _compute_start_time(self): """ @@ -93,8 +100,7 @@ class WorkLogSetting(models.Model): @api.onchange('day_off_id') def _onchange_day_off_id(self): # 先删除之前创建的工作日历事件记录 - self.env['sf.work.schedule.calendar'].search([ - ('calendar_code', '=', self.code), ('name_id', '=', self.name)]).unlink() + # self.env['sf.work.schedule.calendar'].search([('calendar_code', '=', self.code)]).unlink() # 获取当年的一月一号的日期 year = fields.Datetime.now().year # 2023 @@ -124,15 +130,19 @@ class WorkLogSetting(models.Model): ints += 1 # 创建工作日历的休息日事件 - # day_off_ids = self.day_off_id.mapped('name') - # for week in day_off_ids: - # num = desc[week] - # while num <= 30: - # target_date = first_day + timedelta(days=num) - # self.env['sf.work.schedule.calendar'].create({'name': '休息日', - # 'name_id': self.name.id, - # 'date_time': target_date}) - # num += 7 + day_off_ids = self.day_off_id.mapped('name') + record = self.env['sf.work.log.setting'].search([('code', '=', self.code)]) + # record.setting_to_calendar_ids.unlink() + # self.env.cr.commit() + for week in day_off_ids: + num = desc[week] + while num <= 30: + target_date = first_day + timedelta(days=num) + num += 7 + self.env['sf.work.schedule.calendar'].create({'name': '休息日', + 'name_id': record.id, + 'calendar_code': self.code, + 'date_time': target_date}) class WorkingShift(models.Model): @@ -182,9 +192,9 @@ class WorkScheduleCalendar(models.Model): name = fields.Selection([('休息日', '休息日'), ('计划停机', '计划停机')], '日历事件名称') date_time = fields.Date('休息时间') - name_id = fields.Many2one('sf.work.log.setting', '工作日历名称') calendar_code = fields.Char('工作日历编码') + day_off_id = fields.Many2many('sf.day.off', string='休息日') scheduled_outage = fields.Char('计划停机') monthly_rest_days = fields.Char('月休息天数', readonly=True) @@ -192,10 +202,5 @@ class WorkScheduleCalendar(models.Model): monthly_planned_downtime = fields.Char('月计划停机时长', readonly=True) annual_planned_downtime = fields.Char('年计划停机时长', readonly=True) - @api.onchange('name_id') - def _onchange_name_id(self): - for record in self: - record.calendar_code = record.name_id.code - diff --git a/sf_plan_management/views/menu_view.xml b/sf_plan_management/views/menu_view.xml index 926b7ea7..793f381d 100644 --- a/sf_plan_management/views/menu_view.xml +++ b/sf_plan_management/views/menu_view.xml @@ -41,7 +41,7 @@ /> + @@ -182,7 +183,7 @@
- 工作安排日历 + 工作日历 sf.work.schedule.calendar @@ -194,7 +195,7 @@ - 工作安排日历 + 工作日历 sf.work.schedule.calendar @@ -204,7 +205,7 @@ - 工作安排日历 + 工作日历 sf.work.schedule.calendar calendar,search,tree,form