From c1935e62b9bc3e3cfd3cf5eca8a655b61d812847 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 13 Jun 2024 17:24:46 +0800 Subject: [PATCH 01/12] =?UTF-8?q?1=E3=80=81=E9=87=8D=E6=9E=84=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E5=B7=A5=E5=BA=8F=E7=9A=84=E7=94=9F=E6=88=90=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 79 ++++++++++++++--------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 34e00aee..01067082 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -484,46 +484,63 @@ class MrpProduction(models.Model): def _reset_work_order_sequence(self): for rec in self: sequence_list = {} + # 产品模型类型 model_type_id = rec.product_id.product_model_type_id + # 产品加工面板 + model_processing_panel = rec.product_id.model_processing_panel if model_type_id: - tmpl_num = 1 - # 成品工序 - product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids - if product_routing_tmpl_ids: - for tmpl_id in product_routing_tmpl_ids: - sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num}) - tmpl_num += 1 - # 表面工艺工序 - # 模型类型的表面工艺工序模版 - surface_tmpl_ids = model_type_id.surface_technics_routing_tmpl_ids - # 产品选择的表面工艺 - model_process_parameters_ids = rec.product_id.model_process_parameters_ids - process_dict = {} - if model_process_parameters_ids: - for process_parameters_id in model_process_parameters_ids: - process_id = process_parameters_id.process_id - for surface_tmpl_id in surface_tmpl_ids: - if process_id == surface_tmpl_id.route_workcenter_id.surface_technics_id: - surface_tmpl_name = surface_tmpl_id.route_workcenter_id.name - process_dict.update({int(process_id.category_id.code): '%s-%s' % ( - surface_tmpl_name, process_parameters_id.name)}) - process_list = sorted(process_dict.keys()) - for process_num in process_list: - sequence_list.update({process_dict.get(process_num): tmpl_num}) - tmpl_num += 1 - # 坯料工序 - tmpl_num = 1 - embryo_routing_tmpl_ids = model_type_id.embryo_routing_tmpl_ids - if embryo_routing_tmpl_ids: - for tmpl_id in embryo_routing_tmpl_ids: - sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num}) + if model_processing_panel: + tmpl_num = 1 + panel_list = model_processing_panel.split(',') + for panel in panel_list: + panel_sequence_list = {} + # 成品工序 + product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids + if product_routing_tmpl_ids: + for tmpl_id in product_routing_tmpl_ids: + panel_sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num}) + tmpl_num += 1 + sequence_list.update({panel: panel_sequence_list}) + # 表面工艺工序 + # 模型类型的表面工艺工序模版 + surface_tmpl_ids = model_type_id.surface_technics_routing_tmpl_ids + # 产品选择的表面工艺 + model_process_parameters_ids = rec.product_id.model_process_parameters_ids + process_dict = {} + if model_process_parameters_ids: + for process_parameters_id in model_process_parameters_ids: + process_id = process_parameters_id.process_id + for surface_tmpl_id in surface_tmpl_ids: + if process_id == surface_tmpl_id.route_workcenter_id.surface_technics_id: + surface_tmpl_name = surface_tmpl_id.route_workcenter_id.name + process_dict.update({int(process_id.category_id.code): '%s-%s' % ( + surface_tmpl_name, process_parameters_id.name)}) + process_list = sorted(process_dict.keys()) + for process_num in process_list: + sequence_list.update({process_dict.get(process_num): tmpl_num}) tmpl_num += 1 + # 坯料工序 + tmpl_num = 1 + embryo_routing_tmpl_ids = model_type_id.embryo_routing_tmpl_ids + if embryo_routing_tmpl_ids: + for tmpl_id in embryo_routing_tmpl_ids: + sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num}) + tmpl_num += 1 + else: + raise ValidationError('该产品【加工面板】为空!') + else: raise ValidationError('该产品没有选择【模版类型】!') for work in rec.workorder_ids: if sequence_list.get(work.name): work.sequence = sequence_list[work.name] + elif sequence_list.get(work.processing_panel): + processing_panel = sequence_list.get(work.processing_panel) + if processing_panel.get(work.name): + work.sequence = processing_panel[work.name] + else: + raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name) else: raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name) # if work.name == '获取CNC加工程序': From de6014d1dda1fdb0ce3e50a00f72d3b4f340ec25 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 21 Jun 2024 17:39:15 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=A5=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E4=BA=A7=E7=BA=BF=E6=8E=A5=E5=8F=A3=EF=BC=9A?= =?UTF-8?q?=E5=BD=93RFID=E4=B8=8D=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E4=BA=A7=E7=BA=BF=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 78 +++++++++++---------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 61bc83ea..75badcc8 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -460,25 +460,27 @@ class Manufacturing_Connect(http.Controller): if f'RfidCode{i}' in ret: rfid_code = ret[f'RfidCode{i}'] logging.info('RfidCode:%s' % rfid_code) - domain = [ - ('rfid_code', '=', rfid_code), - ('routing_type', '=', 'CNC加工') - ] - workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc') - if workorder: - for order in workorder: - if order.production_id.production_line_state == '待上产线': - logging.info( - '制造订单产线状态:%s' % order.production_id.production_line_state) - order.production_id.write({'production_line_state': '已上产线'}) - workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search([ - ('rfid_code', '=', rfid_code), ('type', '=', '上产线'), - ('production_id', '=', order.production_id.id)]) - if workpiece_delivery.status == '待下发': - workpiece_delivery.write({'is_manual_work': True}) - else: - res = {'Succeed': False, 'ErrorCode': 204, - 'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']} + if rfid_code is not None: + domain = [ + ('rfid_code', '=', rfid_code), + ('routing_type', '=', 'CNC加工') + ] + workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc') + if workorder: + for order in workorder: + if order.production_id.production_line_state == '待上产线': + logging.info( + '制造订单产线状态:%s' % order.production_id.production_line_state) + order.production_id.write({'production_line_state': '已上产线'}) + workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( + [ + ('rfid_code', '=', rfid_code), ('type', '=', '上产线'), + ('production_id', '=', order.production_id.id)]) + if workpiece_delivery.status == '待下发': + workpiece_delivery.write({'is_manual_work': True}) + else: + res = {'Succeed': False, 'ErrorCode': 204, + 'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']} else: res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'} else: @@ -515,24 +517,26 @@ class Manufacturing_Connect(http.Controller): if f'RfidCode{i}' in ret: rfid_code = ret[f'RfidCode{i}'] logging.info('RfidCode:%s' % rfid_code) - domain = [ - ('rfid_code', '=', rfid_code), - ('routing_type', '=', 'CNC加工') - ] - workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc') - if workorder: - for order in workorder: - if order.production_id.production_line_state == '已上产线': - logging.info( - '制造订单产线状态:%s' % order.production_id.production_line_state) - order.production_id.write({'production_line_state': '已下产线'}) - 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) - else: - res = {'Succeed': False, 'ErrorCode': 204, - 'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']} + if rfid_code is not None: + domain = [ + ('rfid_code', '=', rfid_code), + ('routing_type', '=', 'CNC加工') + ] + workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc') + if workorder: + for order in workorder: + if order.production_id.production_line_state == '已上产线': + logging.info( + '制造订单产线状态:%s' % order.production_id.production_line_state) + order.production_id.write({'production_line_state': '已下产线'}) + 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) + else: + res = {'Succeed': False, 'ErrorCode': 204, + 'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']} if delivery_Arr: logging.info('delivery_Arr:%s' % delivery_Arr) delivery_workpiece = request.env['sf.workpiece.delivery'].sudo().search( From e453508f17233787215b2aec8ccb117f06e5250c Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 24 Jun 2024 14:18:42 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E6=B8=85=E5=8D=95=E6=9F=A5=E8=AF=A2=E5=88=97?= =?UTF-8?q?=E8=A1=A8:=E9=83=A8=E5=88=86=E5=AD=97=E6=AE=B5=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/views/tool_views.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index 1e82b8c2..c3bbb6d1 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -555,9 +555,9 @@ sf.tool.inventory - + - + From ec30a07394b561f93b6df76b96e15054c215031c Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 24 Jun 2024 14:54:33 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 8daf1488..7eea666b 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -1028,7 +1028,7 @@ class ProductProduct(models.Model): 'product_id': self.id, 'lot_id': lot_id.id, 'move_id': stock_move_id.id, - 'destination_location_id': shelf_location_id.id, + 'destination_location_id': shelf_location_id.id if shelf_location_id else False, 'install_tool_time': fields.Datetime.now(), 'qty_done': 1.0, 'state': 'done', From a82a54c4641d280bc11afbe34b336c5929408d74 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 24 Jun 2024 15:40:51 +0800 Subject: [PATCH 05/12] =?UTF-8?q?1=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E6=B8=85=E5=8D=95=E5=81=9A=E7=BC=96=E8=BE=91=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=EF=BC=9B2=E3=80=81=E5=88=80=E5=85=B7=E6=8B=86?= =?UTF-8?q?=E8=A7=A3=E2=80=94=E2=80=94=E6=8A=A5=E5=BA=9F=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=9B3=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E5=87=BA=E5=85=A5=E5=BA=93=E6=B7=BB=E5=8A=A0=E5=88=80=E5=85=B7?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/tool_base_new.py | 2 +- sf_base/views/tool_views.xml | 4 ++-- sf_tool_management/models/base.py | 14 ++++++++++++-- sf_tool_management/models/functional_tool.py | 16 ++++++++++++++++ .../views/functional_tool_views.xml | 3 ++- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index 7977ed80..98eea36c 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -331,7 +331,7 @@ class ToolInventory(models.Model): work_material = fields.Selection([('钢', '钢'), ('铝', '铝')], string='加工材料') life_span = fields.Float('寿命(min)') - tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组') + tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组', required=True) active = fields.Boolean('已归档', default=True) diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index 1e82b8c2..05196a19 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -555,9 +555,9 @@ sf.tool.inventory - + - + diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 8daf1488..61156536 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -581,6 +581,15 @@ class FunctionalToolAssembly(models.Model): active = fields.Boolean(string='已归档', default=True) + def action_open_reference1(self): + self.ensure_one() + return { + 'res_model': self._name, + 'type': 'ir.actions.act_window', + 'views': [[False, "form"]], + 'res_id': self.id, + } + def put_start_preset(self): self.search([('start_preset_bool', '=', True)]).write({'start_preset_bool': False}) self.write({ @@ -750,7 +759,8 @@ class FunctionalToolDismantle(models.Model): return 'GNDJ-CJD-%s-%s' % (datetime, num) functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True, - domain=[('functional_tool_status', '!=', '已拆除')]) + domain=[('functional_tool_status', '!=', '已拆除'), + ('current_location', '=', '刀具房')]) tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, compute='_compute_functional_tool_num') tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_functional_tool_num', store=True) @@ -1028,7 +1038,7 @@ class ProductProduct(models.Model): 'product_id': self.id, 'lot_id': lot_id.id, 'move_id': stock_move_id.id, - 'destination_location_id': shelf_location_id.id, + 'destination_location_id': shelf_location_id.id if shelf_location_id else False, 'install_tool_time': fields.Datetime.now(), 'qty_done': 1.0, 'state': 'done', diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index 45f52f4f..18f0a466 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -387,6 +387,22 @@ class StockMoveLine(models.Model): names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) return categories.browse(names) + def action_open_reference1(self): + self.ensure_one() + if self.functional_tool_name_id: + action = self.functional_tool_name_id.action_open_reference1() + return action + elif self.move_id: + action = self.move_id.action_open_reference() + if action['res_model'] != 'stock.move': + return action + return { + 'res_model': self._name, + 'type': 'ir.actions.act_window', + 'views': [[False, "form"]], + 'res_id': self.id, + } + class RealTimeDistributionOfFunctionalTools(models.Model): _name = 'sf.real.time.distribution.of.functional.tools' diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml index 6d812368..6fde82a0 100644 --- a/sf_tool_management/views/functional_tool_views.xml +++ b/sf_tool_management/views/functional_tool_views.xml @@ -477,7 +477,8 @@ 功能刀具出入库记录 stock.move.line - + From 828b4b0f6b6b6e5395809c6b21dc5b933f841a5f Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 24 Jun 2024 16:55:42 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E6=B8=85=E5=8D=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/views/tool_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index c3bbb6d1..87dbd94c 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -557,7 +557,7 @@ - + From 95e89d8979a72fc57286ad06f1a65f8811378e4d Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 24 Jun 2024 17:10:39 +0800 Subject: [PATCH 07/12] 1 --- sf_base/views/tool_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index 05196a19..fff58007 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -557,7 +557,7 @@ - + From 665ebaab9ea4c0620dcc1df1a21bf45a0480a383 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 24 Jun 2024 17:28:06 +0800 Subject: [PATCH 08/12] =?UTF-8?q?1=E3=80=81=E9=87=8D=E6=96=B0=E4=B8=8B?= =?UTF-8?q?=E5=8F=91NC=E7=A8=8B=E5=BA=8F=E6=8C=89=E9=94=AE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/views/compensation.xml | 1 + sf_manufacturing/views/mrp_workorder_view.xml | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sf_machine_connect/views/compensation.xml b/sf_machine_connect/views/compensation.xml index d3b14535..07173c17 100644 --- a/sf_machine_connect/views/compensation.xml +++ b/sf_machine_connect/views/compensation.xml @@ -23,6 +23,7 @@