From 3404cccdc8e0e7dde762a77988e14b675658d407 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 16 Jul 2024 15:33:27 +0800 Subject: [PATCH 1/6] =?UTF-8?q?1=E3=80=81=E8=B4=A7=E6=9E=B6=E3=80=81?= =?UTF-8?q?=E8=B4=A7=E4=BD=8D=E6=B7=BB=E5=8A=A0=E5=BE=AA=E7=8E=AF=E8=B4=A7?= =?UTF-8?q?=E4=BD=8D=E6=A0=87=E7=AD=BE=EF=BC=9B2=E3=80=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E6=8B=86=E8=A7=A3=E9=80=89=E5=8F=96?= =?UTF-8?q?=E6=B3=95=E4=BA=BA=E8=B4=A7=E4=BD=8D=E6=B7=BB=E5=8A=A0=E5=8F=AA?= =?UTF-8?q?=E8=83=BD=E9=80=89=E6=8B=A9=E5=BE=AA=E7=8E=AF=E8=B4=A7=E4=BD=8D?= =?UTF-8?q?=E7=9A=84=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 10 +++++----- sf_warehouse/models/model.py | 2 ++ sf_warehouse/views/shelf_location.xml | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 182141cf..0fb31704 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -803,7 +803,7 @@ class FunctionalToolDismantle(models.Model): integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次', compute='_compute_functional_tool_num', store=True) integral_freight_id = fields.Many2one('sf.shelf.location', '整体式刀具目标货位', - domain="[('product_id', 'in', (integral_product_id, False))]") + domain="[('product_id', 'in', (integral_product_id, False)),('rotative_Boolean', '=', True)]") # 刀片 blade_product_id = fields.Many2one('product.product', string='刀片', compute='_compute_functional_tool_num', @@ -813,7 +813,7 @@ class FunctionalToolDismantle(models.Model): blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id') blade_lot_id = fields.Many2one('stock.lot', string='刀片批次', compute='_compute_functional_tool_num', store=True) blade_freight_id = fields.Many2one('sf.shelf.location', '刀片目标货位', - domain="[('product_id', 'in', (blade_product_id, False))]") + domain="[('product_id', 'in', (blade_product_id, False)),('rotative_Boolean', '=', True)]") # 刀杆 bar_product_id = fields.Many2one('product.product', string='刀杆', compute='_compute_functional_tool_num', @@ -823,7 +823,7 @@ class FunctionalToolDismantle(models.Model): bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id') bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次', compute='_compute_functional_tool_num', store=True) bar_freight_id = fields.Many2one('sf.shelf.location', '刀杆目标货位', - domain="[('product_id', 'in', (bar_product_id, False))]") + domain="[('product_id', 'in', (bar_product_id, False)),('rotative_Boolean', '=', True)]") # 刀盘 pad_product_id = fields.Many2one('product.product', string='刀盘', compute='_compute_functional_tool_num', @@ -833,7 +833,7 @@ class FunctionalToolDismantle(models.Model): pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id') pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次', compute='_compute_functional_tool_num', store=True) pad_freight_id = fields.Many2one('sf.shelf.location', '刀盘目标货位', - domain="[('product_id', 'in', (pad_product_id, False))]") + domain="[('product_id', 'in', (pad_product_id, False)),('rotative_Boolean', '=', True)]") # 夹头 chuck_product_id = fields.Many2one('product.product', string='夹头', compute='_compute_functional_tool_num', @@ -843,7 +843,7 @@ class FunctionalToolDismantle(models.Model): chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id') chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次', compute='_compute_functional_tool_num', store=True) chuck_freight_id = fields.Many2one('sf.shelf.location', '夹头目标货位', - domain="[('product_id', 'in', (chuck_product_id, False))]") + domain="[('product_id', 'in', (chuck_product_id, False)),('rotative_Boolean', '=', True)]") @api.onchange('functional_tool_id') def _onchange_freight(self): diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index ee212b2a..770d2672 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -254,6 +254,7 @@ class SfShelf(models.Model): shelf_height = fields.Float(string='货架高度(m)') shelf_layer = fields.Integer(string='货架层数') layer_capacity = fields.Integer(string='层数容量') + shelf_rotative_Boolean = fields.Boolean('循环货架', default=False) # 是否有货位 is_there_area = fields.Boolean(string='是否有货位', compute='_compute_is_there_area', default=False, store=True) @@ -361,6 +362,7 @@ class ShelfLocation(models.Model): name = fields.Char('货位名称', required=True, size=20) barcode = fields.Char('货位编码', copy=False, size=50) + rotative_Boolean = fields.Boolean('循环货位', related='shelf_id.shelf_rotative_Boolean', store=True) qr_code = fields.Binary(string='二维码', compute='_compute_location_qr_code', store=True) # 货架 diff --git a/sf_warehouse/views/shelf_location.xml b/sf_warehouse/views/shelf_location.xml index 418f7d5c..747c25a2 100644 --- a/sf_warehouse/views/shelf_location.xml +++ b/sf_warehouse/views/shelf_location.xml @@ -23,6 +23,7 @@ + @@ -169,6 +170,7 @@ + From d0be097a9befef7412b60ee2afe0cd78c2821b9f Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 24 Jul 2024 16:19:29 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=8A=A0=E5=B7=A5?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=AD=89=E9=A1=B5=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/models/ftp_client.py | 44 ++++++++--------- sf_maintenance/models/sf_maintenance_logs.py | 8 ++-- .../views/maintenance_logs_views.xml | 47 ++++++++++--------- .../views/production_line_view.xml | 2 +- 4 files changed, 53 insertions(+), 48 deletions(-) diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py index ec46d620..2d9ad9a5 100644 --- a/sf_machine_connect/models/ftp_client.py +++ b/sf_machine_connect/models/ftp_client.py @@ -245,32 +245,32 @@ class Machine_ftp(models.Model): program_status = fields.Char('程序运行状态', readonly=True) current_program = fields.Char('机床当前执行指令', readonly=True) current_program_seq = fields.Char('机床当前执行语句号', readonly=True) - x_abs_pos = fields.Char('机床X轴当前位置', readonly=True) - y_abs_pos = fields.Char('机床Y轴当前位置', readonly=True) - z_abs_pos = fields.Char('机床Z轴当前位置', readonly=True) + x_abs_pos = fields.Char('机床X轴当前位置(mm)', readonly=True) + y_abs_pos = fields.Char('机床Y轴当前位置(mm)', readonly=True) + z_abs_pos = fields.Char('机床Z轴当前位置(mm)', readonly=True) # 机床设定进给速度, 机床实际进给速度, 机床设定主轴转速, 机床实际主轴转速, 机床主轴负载, 机床X轴伺服轴负载, 机床Y轴伺服轴负载 # 机床Z轴伺服轴负载, 机床快速移动倍率, 机床进给倍率, 机床X轴机械坐标, 机床Y轴机械坐标, 机床Z轴机械坐标, 机床X轴相对工件坐标 # 机床Y轴相对工件坐标, 机床Z轴相对工件坐标, 机床X轴目标距离, 机床Y轴目标距离, 机床Z轴目标距离 - feed_speed_set = fields.Char('机床设定进给速度', readonly=True) - act_feed_speed = fields.Char('机床实际进给速度', readonly=True) - spindle_speed_set = fields.Char('机床设定主轴转速', readonly=True) - act_spindle_speed = fields.Char('机床实际主轴转速', readonly=True) - spindle_load = fields.Char('机床主轴负载', readonly=True) - x_axis_load = fields.Char('机床X轴伺服轴负载', readonly=True) - y_axis_load = fields.Char('机床Y轴伺服轴负载', readonly=True) - z_axis_load = fields.Char('机床Z轴伺服轴负载', readonly=True) - rapid_feed = fields.Char('机床快速移动倍率', readonly=True) - feed_rate = fields.Char('机床进给倍率', readonly=True) - x_mach_coord = fields.Char('机床X轴机械坐标', readonly=True) - y_mach_coord = fields.Char('机床Y轴机械坐标', readonly=True) - z_mach_coord = fields.Char('机床Z轴机械坐标', readonly=True) - x_rel_coord = fields.Char('机床X轴相对工件坐标', readonly=True) - y_rel_coord = fields.Char('机床Y轴相对工件坐标', readonly=True) - z_rel_coord = fields.Char('机床Z轴相对工件坐标', readonly=True) - x_dis_coord = fields.Char('机床X轴目标距离', readonly=True) - y_dis_coord = fields.Char('机床Y轴目标距离', readonly=True) - z_dis_coord = fields.Char('机床Z轴目标距离', readonly=True) + feed_speed_set = fields.Char('机床设定进给速度(mm/min)', readonly=True) + act_feed_speed = fields.Char('机床实际进给速度(mm/min)', readonly=True) + spindle_speed_set = fields.Char('机床设定主轴转速(r/min)', readonly=True) + act_spindle_speed = fields.Char('机床实际主轴转速(r/min)', readonly=True) + spindle_load = fields.Char('机床主轴负载(%)', readonly=True) + x_axis_load = fields.Char('机床X轴伺服轴负载(%)', readonly=True) + y_axis_load = fields.Char('机床Y轴伺服轴负载(%)', readonly=True) + z_axis_load = fields.Char('机床Z轴伺服轴负载(%)', readonly=True) + rapid_feed = fields.Char('机床快速移动倍率(%)', readonly=True) + feed_rate = fields.Char('机床进给倍率(%)', readonly=True) + x_mach_coord = fields.Char('机床X轴机械坐标(mm)', readonly=True) + y_mach_coord = fields.Char('机床Y轴机械坐标(mm)', readonly=True) + z_mach_coord = fields.Char('机床Z轴机械坐标(mm)', readonly=True) + x_rel_coord = fields.Char('机床X轴相对工件坐标(mm)', readonly=True) + y_rel_coord = fields.Char('机床Y轴相对工件坐标(mm)', readonly=True) + z_rel_coord = fields.Char('机床Z轴相对工件坐标(mm)', readonly=True) + x_dis_coord = fields.Char('机床X轴目标距离(mm)', readonly=True) + y_dis_coord = fields.Char('机床Y轴目标距离(mm)', readonly=True) + z_dis_coord = fields.Char('机床Z轴目标距离(mm)', readonly=True) # 故障报警时间, 故障报警信息, 故障消除时间(复原时间) alarm_time = fields.Char('故障报警时间', readonly=True) diff --git a/sf_maintenance/models/sf_maintenance_logs.py b/sf_maintenance/models/sf_maintenance_logs.py index 2dc26f7e..7f80e163 100644 --- a/sf_maintenance/models/sf_maintenance_logs.py +++ b/sf_maintenance/models/sf_maintenance_logs.py @@ -10,21 +10,21 @@ class SfMaintenanceLogs(models.Model): name = fields.Char(string='名称') type = fields.Selection([('type1', '类型1'), ('type2', '类型2')], string='类型') brand = fields.Many2one('sf.machine.brand', related='maintenance_equipment_id.brand_id', string='品牌') - maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='设备') + maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='机台号') maintenance_equipment_oee_id = fields.Many2one('maintenance.equipment.oee', string='设备oee') code_location = fields.Char(string='编码位置') fault_type = fields.Selection( [('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='故障类型') fault_code = fields.Char(string='故障代码') - fault_alarm_info = fields.Char(string='故障报警信息') + fault_alarm_info = fields.Text(string='故障报警信息') alarm_level = fields.Selection([('一级', '一级(严重)'), ('二级', '二级(中等)'), ('三级', '三级(轻微)')], string='报警级别') - alarm_time = fields.Datetime(string='报警时间') + alarm_time = fields.Datetime(string='故障报警时间') alarm_way = fields.Selection([('文本提示报警', '文本提示报警'), ('声光报警', '声光报警'), ('图文报警', '图文报警')], string='报警方式') fault_process = fields.Text(string='故障处理方法') operator = fields.Many2one('res.users', string='处理人') - recovery_time = fields.Datetime(string='复原时间') + recovery_time = fields.Datetime(string='故障消除时间') fault_duration = fields.Float(string='故障时长') note = fields.Text(string='备注') active = fields.Boolean('Active', default=True) diff --git a/sf_maintenance/views/maintenance_logs_views.xml b/sf_maintenance/views/maintenance_logs_views.xml index 087f6ffb..76e52d55 100644 --- a/sf_maintenance/views/maintenance_logs_views.xml +++ b/sf_maintenance/views/maintenance_logs_views.xml @@ -7,22 +7,20 @@ sf.maintenance.logs - - + - - - + + - + @@ -45,25 +43,32 @@ - - - + + - - - - - - - + - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/sf_manufacturing/views/production_line_view.xml b/sf_manufacturing/views/production_line_view.xml index c43885b4..18b628cd 100644 --- a/sf_manufacturing/views/production_line_view.xml +++ b/sf_manufacturing/views/production_line_view.xml @@ -100,7 +100,7 @@ sf.maintenance.logs - + From d9e5ffa68d86d67b1f8256593911808d2c154719 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Thu, 25 Jul 2024 14:05:35 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E3=80=81oee=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_maintenance/models/sf_maintenance_oee.py | 67 ++++-- sf_maintenance/security/ir.model.access.csv | 3 + .../views/maintenance_equipment_oee_views.xml | 27 ++- .../views/maintenance_logs_views.xml | 227 ++++++++++++++++++ 4 files changed, 296 insertions(+), 28 deletions(-) diff --git a/sf_maintenance/models/sf_maintenance_oee.py b/sf_maintenance/models/sf_maintenance_oee.py index 6d76ffbe..6e8db042 100644 --- a/sf_maintenance/models/sf_maintenance_oee.py +++ b/sf_maintenance/models/sf_maintenance_oee.py @@ -7,20 +7,23 @@ class SfMaintenanceEquipmentOEE(models.Model): _description = '设备OEE' name = fields.Char('设备oee') - equipment_id = fields.Many2one('maintenance.equipment', '设备', + equipment_id = fields.Many2one('maintenance.equipment', '机台号', domain="[('category_id.equipment_type', '=', '机床'),('state_zc', '=', '已注册')]") type_id = fields.Many2one('sf.machine_tool.type', '型号', related='equipment_id.type_id') - machine_tool_picture = fields.Binary('设备图片', related='equipment_id.machine_tool_picture') + machine_tool_picture = fields.Binary('设备图片', related='equipment_id.machine_tool_picture') state = fields.Selection( [("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"), ("封存(报废)", "封存(报废)")], default='正常', string="机床状态", related='equipment_id.state') - run_time = fields.Float('正常运行总时长(h)') - equipment_time = fields.Float('总时长(h)') - done_nums = fields.Integer('累计加工总件数') - utilization_rate = fields.Char('开动率') - fault_time = fields.Float('故障停机总时长(h)') + run_time = fields.Float('加工时长(h)') + equipment_time = fields.Float('开机时长(h)') + done_nums = fields.Integer('加工件数') + utilization_rate = fields.Char('可用率') + fault_time = fields.Float('故障时长') fault_nums = fields.Integer('故障次数') + # 故障率 + fault_rate = fields.Char('故障率') + # 设备故障日志 sf_maintenance_logs_ids = fields.One2many('sf.maintenance.logs', 'maintenance_equipment_oee_id', '设备故障日志', related='equipment_id.sf_maintenance_logs_ids') oee_logs = fields.One2many('maintenance.equipment.oee.logs', 'equipment_oee_id', string='运行日志') @@ -38,12 +41,46 @@ class SfMaintenanceEquipmentOEELog(models.Model): _name = 'maintenance.equipment.oee.logs' _description = '设备运行日志' - name = fields.Char('运行日志') - run_time = fields.Datetime('时间') - state = fields.Selection([("开机", "开机"), ("关机", "关机"), ("等待", "等待"), ("开始加工", "开始加工"), - ("结束加工", "结束加工"), ("故障", "故障"), - ("检修", "检修"), ("保养", "保养")], default="", string="事件/状态") - workorder_id = fields.Char('加工订单') - time = fields.Char('持续时长') - color = fields.Char('颜色', default=1) + equipment_id = fields.Many2one('maintenance.equipment', '机台号') + name = fields.Char('设备名称') + machine_tool_picture = fields.Binary('设备图片') + type_id = fields.Many2one('sf.machine_tool.type', '品牌型号') + state = fields.Selection([("加工", "加工"), ("关机", "关机"), ("待机", "待机"), ("故障", "故障"), + ("检修", "检修"), ("保养", "保养")], default="", string="实时状态") + online_time = fields.Char('开机时长') + + offline_time = fields.Char('关机时长') + offline_nums = fields.Integer('关机次数') + # 待机时长 + + idle_time = fields.Char('待机时长') + + # 待机率 + idle_rate = fields.Char('待机率') + + work_time = fields.Char('加工时长') + work_rate = fields.Char('可用率') + fault_time = fields.Char('故障时长') + fault_rate = fields.Char('故障率') + fault_nums = fields.Integer('故障次数') + + detail_ids = fields.One2many('maintenance.equipment.oee.log.detail', 'log_id', string='日志详情') + + # maintenance_time = fields.Char('维保时长') + # work_nums = fields.Integer('加工件数') equipment_oee_id = fields.Many2one('maintenance.equipment.oee', '设备OEE') + + +# 设备运行日志详情 +class SfMaintenanceEquipmentOEELogDetail(models.Model): + _name = 'maintenance.equipment.oee.log.detail' + _description = '设备运行日志详情' + + sequence = fields.Integer('序号') + time = fields.Datetime('时间') + state = fields.Selection([("加工", "加工"), ("关机", "关机"), ("待机", "待机"), ("故障", "故障"), + ("检修", "检修"), ("保养", "保养")], default="", string="事件/状态") + production_id = fields.Many2one('mrp.production', '加工工单') + + log_id = fields.Many2one('maintenance.equipment.oee.logs', '日志') + diff --git a/sf_maintenance/security/ir.model.access.csv b/sf_maintenance/security/ir.model.access.csv index abbd4878..fec317c2 100644 --- a/sf_maintenance/security/ir.model.access.csv +++ b/sf_maintenance/security/ir.model.access.csv @@ -67,3 +67,6 @@ access_sf_cutting_tool_type_admin_sf_group_equipment_user,sf_cutting_tool_type_a access_sf_cutting_tool_type_group_purchase_director_sf_group_equipment_user,sf_cutting_tool_type_group_purchase_director,sf_base.model_sf_cutting_tool_type,sf_maintenance.sf_group_equipment_user,1,0,0,0 access_sf_cutting_tool_type_group_sale_director_sf_group_equipment_user,sf_cutting_tool_type_group_sale_director,sf_base.model_sf_cutting_tool_type,sf_maintenance.sf_group_equipment_user,1,0,0,0 access_sf_cutting_tool_type_group_plan_director_sf_group_equipment_user,sf_cutting_tool_type_group_plan_director,sf_base.model_sf_cutting_tool_type,sf_maintenance.sf_group_equipment_user,1,0,0,0 + +access_maintenance_equipment_oee_logs,maintenance_equipment_oee_logs,model_maintenance_equipment_oee_logs,sf_maintenance.sf_group_equipment_manager,1,1,1,0 +access_maintenance_equipment_oee_log_detail,maintenance_equipment_oee_log_detail,model_maintenance_equipment_oee_log_detail,sf_maintenance.sf_group_equipment_manager,1,1,1,0 \ No newline at end of file diff --git a/sf_maintenance/views/maintenance_equipment_oee_views.xml b/sf_maintenance/views/maintenance_equipment_oee_views.xml index 091e3c47..9370fbbc 100644 --- a/sf_maintenance/views/maintenance_equipment_oee_views.xml +++ b/sf_maintenance/views/maintenance_equipment_oee_views.xml @@ -14,6 +14,7 @@ + @@ -49,19 +50,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/sf_maintenance/views/maintenance_logs_views.xml b/sf_maintenance/views/maintenance_logs_views.xml index 76e52d55..8c80372d 100644 --- a/sf_maintenance/views/maintenance_logs_views.xml +++ b/sf_maintenance/views/maintenance_logs_views.xml @@ -105,6 +105,233 @@ + + + maintenance.logs.run.tree + maintenance.equipment.oee.logs + + + + + + + + + maintenance.logs.run.form + maintenance.equipment.oee.logs + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + maintenance.logs.run.detail.tree + maintenance.equipment.oee.log.detail + + + + + + + + + + + + maintenance.logs.run.detail.form + maintenance.equipment.oee.log.detail + +
+
+ +
+ +
+

+ +

+
+ + + + + + + + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 设备运行日志 + ir.actions.act_window + maintenance.equipment.oee.logs + + tree,form + + + +

+ 设备运行日志 +

+
+
+ + + + From 9655281b671b83a2d17f08f3efc4a16620ab9e2a Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 25 Jul 2024 15:21:36 +0800 Subject: [PATCH 4/6] =?UTF-8?q?1=E3=80=81=E8=A7=A3=E5=86=B3=20=E7=BC=BA?= =?UTF-8?q?=E5=88=80=E7=8A=B6=E6=80=81=E7=AC=AC=E4=B8=80=E5=BC=A0=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E7=8A=B6=E6=80=81=E4=B8=8D=E5=AF=B9=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 520af4f4..dc172a46 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -820,6 +820,10 @@ class ResMrpWorkOrder(models.Model): # else: # if workorder.state not in ['cancel', 'rework']: # workorder.state = 'rework' + if workorder.production_id.state == 'pending_cam': + if workorder.routing_type == '装夹预调' and workorder.state in ['ready', 'waiting']: + if workorder.production_id.tool_state in ['1', '2']: + workorder.state = 'waiting' # elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'cancel', 'progress', # 'rework']: # per_work = self.env['mrp.workorder'].search( @@ -870,8 +874,12 @@ class ResMrpWorkOrder(models.Model): raise UserError(_('该制造订单还未下发CNC程序,请稍后再试')) else: if self.production_id.tool_state in ['1', '2']: + if self.production_id.tool_state == '1': + state = '缺刀' + else: + state = '无效刀' raise UserError( - f'制造订单【{self.production_id.name}】功能刀具状态为【{self.production_id.tool_state}】!') + f'制造订单【{self.production_id.name}】功能刀具状态为【{state}】!') if self.routing_type == '解除装夹': ''' 记录开始时间 From 9eddfe36d6f48326e75942ab8a72149670a54407 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 25 Jul 2024 15:22:48 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=94=E5=B7=A5-?= =?UTF-8?q?=E5=B7=A5=E4=BB=B6=E9=85=8D=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 11 ++++++++--- sf_manufacturing/models/mrp_production.py | 3 ++- sf_manufacturing/models/mrp_workorder.py | 3 ++- sf_manufacturing/views/mrp_workorder_view.xml | 9 ++++++--- sf_manufacturing/wizard/rework_wizard.py | 8 +++++++- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 005e3717..f5a55db2 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -486,7 +486,9 @@ class Manufacturing_Connect(http.Controller): workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( [ ('rfid_code', '=', rfid_code), ('type', '=', '上产线'), - ('production_id', '=', order.production_id.id)]) + ('production_id', '=', order.production_id.id), + ('workorder_id', '=', order.id), + ('workorder_state', '=', 'done')]) if workpiece_delivery.status == '待下发': workpiece_delivery.write({'is_manual_work': True}) else: @@ -548,8 +550,11 @@ class Manufacturing_Connect(http.Controller): workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( [ ('rfid_code', '=', rfid_code), ('type', '=', '下产线'), - ('production_id', '=', order.production_id.id)]) - delivery_Arr.append(workpiece_delivery.id) + ('production_id', '=', order.production_id.id), + ('workorder_id', '=', order.id), + ('workorder_state', '=', 'done')]) + if workpiece_delivery: + delivery_Arr.append(workpiece_delivery.id) else: res = {'Succeed': False, 'ErrorCode': 204, 'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']} diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index ef470678..65c3ebec 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -734,7 +734,7 @@ class MrpProduction(models.Model): for production in self: logging.info('qty_produced:%s' % production.qty_produced) - if production.qty_produced == '0.0': + if production.qty_produced == 0.0: production.qty_produced = 1.0 production.write({ 'date_finished': fields.Datetime.now(), @@ -897,6 +897,7 @@ class MrpProduction(models.Model): result), 'cmm_ids': panel_workorder.cmm_ids.sudo()._json_cmm_program(processing_panel, result), 'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) + logging.info('len(cnc_worksheet):%s' % len(panel_workorder.cnc_worksheet)) pre_workorder = production.workorder_ids.filtered(lambda ap: ap.routing_type == '装夹预调' and ap.processing_panel == processing_panel and ap.state not in ( 'rework', 'done')) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 8781755d..a2745150 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1404,7 +1404,8 @@ class WorkPieceDelivery(models.Model): [('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型') delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration') status = fields.Selection( - [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发', + [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送'), ('已取消', '已取消')], string='状态', + default='待下发', tracking=True) is_cnc_program_down = fields.Boolean('程序是否下发', default=False, tracking=True) is_manual_work = fields.Boolean('人工操作', default=False) diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 0f5a656e..805dcb1f 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -475,7 +475,8 @@ + decoration-danger="status == '待配送'" + decoration-info="status== '已取消'"/> @@ -635,7 +636,9 @@ + decoration-danger="status == '待配送'" + decoration-info="status == '已取消'" + /> @@ -731,7 +734,7 @@ tree,form - [('type','in',['上产线','下产线']),('workorder_state','=','done'),('is_manual_work','=',false)] + [('type','in',['上产线','下产线']),('workorder_state','in',['done','rework']),('is_manual_work','=',false)] diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py index c50e267d..f15f85d1 100644 --- a/sf_manufacturing/wizard/rework_wizard.py +++ b/sf_manufacturing/wizard/rework_wizard.py @@ -69,6 +69,12 @@ class ReworkWizard(models.TransientModel): lambda ap: ap.processing_panel == panel.name and ap.state != 'rework') if panel_workorder: panel_workorder.write({'state': 'rework'}) + panel_workorder.filtered( + lambda wo: wo.routing_type == '装夹预调').workpiece_delivery_ids.filtered( + lambda wd: wd.status == '待下发').write({'status': '已取消'}) + # workpiece = self.env['sf.workpiece.delivery'].search([('status', '=', '待下发'), ( + # 'workorder_id', '=', + # panel_workorder.filtered(lambda wd: wd.routing_type == '装夹预调').id)]) product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search( [('product_model_type_id', '=', self.production_id.product_id.product_model_type_id.id)], order='sequence asc' @@ -137,7 +143,7 @@ class ReworkWizard(models.TransientModel): ret), 'cmm_ids': new_cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel.name, ret), - 'cnc_worksheet': new_cnc_workorder.cnc_worksheet}) + 'cnc_worksheet': cnc_rework.cnc_worksheet}) new_pre_workorder = self.production_id.workorder_ids.filtered(lambda p: p.routing_type == '装夹预调' and p.processing_panel == panel.name and p.state not in ( 'rework', 'done')) From 60b77e09d6590a9886167d845c5e2d2feb5a9fbe Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 25 Jul 2024 15:40:44 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=A5=E4=BB=B6?= =?UTF-8?q?=E9=85=8D=E9=80=81=E7=9B=AE=E7=9A=84=E7=94=9F=E4=BA=A7=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index a2745150..ef1f6b6f 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -567,12 +567,16 @@ class ResMrpWorkOrder(models.Model): up_route = self.env['sf.agv.task.route'].search([('route_type', '=', '上产线')], limit=1, order='id asc') down_route = self.env['sf.agv.task.route'].search([('route_type', '=', '下产线')], limit=1, order='id asc') return [ - [0, '', {'production_id': production.id, 'type': '上产线', 'route_id': up_route.id, - 'feeder_station_start_id': up_route.start_site_id.id, - 'feeder_station_destination_id': up_route.end_site_id.id}], - [0, '', {'production_id': production.id, 'type': '下产线', 'route_id': down_route.id, - 'feeder_station_start_id': down_route.start_site_id.id, - 'feeder_station_destination_id': down_route.end_site_id.id}]] + [0, '', + {'production_id': production.id, 'production_line_id': production.production_line_id.id, 'type': '上产线', + 'route_id': up_route.id, + 'feeder_station_start_id': up_route.start_site_id.id, + 'feeder_station_destination_id': up_route.end_site_id.id}], + [0, '', + {'production_id': production.id, 'production_line_id': production.production_line_id.id, 'type': '下产线', + 'route_id': down_route.id, + 'feeder_station_start_id': down_route.start_site_id.id, + 'feeder_station_destination_id': down_route.end_site_id.id}]] # 拼接工单对象属性值(表面工艺) def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id):