From 17e2a3ffc3b31248fb6bed405fd8b71002b611dd Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 5 Jun 2024 16:26:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?cnc=E7=A8=8B=E5=BA=8F=E7=9A=84=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E5=8D=95=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index d8e6fe02..1751a9e3 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1039,10 +1039,8 @@ class CNCprocessing(models.Model): for f in files: if os.path.splitext(f)[1] == ".pdf": full_path = os.path.join(serverdir, root, f) - if full_path is not False: - if not cnc_processing.workorder_id.cnc_worksheet: - cnc_processing.workorder_id.cnc_worksheet = base64.b64encode( - open(full_path, 'rb').read()) + cnc_processing.workorder_id.cnc_worksheet = base64.b64encode( + open(full_path, 'rb').read()) else: if f in program_path: # if cnc_processing.program_name == f.split('.')[0]: From edf8e1004eef039b529d9f5a8659791b5e0fb78d Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 5 Jun 2024 17:00:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=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 | 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 3125cf01..cc12f7f2 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -352,7 +352,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model): cam_plan_ids = self.env['sf.cam.work.order.program.knife.plan'].search([('name', '=', item.name)]) for cam_plan_id in cam_plan_ids: assembly_id = cam_plan_id.sf_functional_tool_assembly_id - if assembly_id.assemble_status == 0 and not assembly_id.start_preset_bool: + if assembly_id.assemble_status in ('0', '待组装') and not assembly_id.start_preset_bool: logging.info('%s删除成功!!!' % assembly_id) assembly_id.sudo().unlink() logging.info('unlink_cam_plan成功!!!') From 5361fa7678e3af32d9a70b160305248e68b5d76b Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 5 Jun 2024 17:14:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcreate=5Fcam=5Fwork=5Fpla?= =?UTF-8?q?n=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 65 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index cc12f7f2..e14094df 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -311,41 +311,42 @@ class CAMWorkOrderProgramKnifePlan(models.Model): 'applicant': None, 'sf_functional_tool_assembly_id': None}) - def create_cam_work_plan(self, cnc_processing): + def create_cam_work_plan(self, cnc_processing_ids): """ 根据传入的工单信息,查询是否有需要的功能刀具,如果没有则生成CAM工单程序用刀计划 """ - status = False - if cnc_processing.cutting_tool_name: - functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search( - [('name', '=', cnc_processing.cutting_tool_name)]) - if functional_tools: - for functional_tool in functional_tools: - if functional_tool.on_tool_stock_num == 0: - if functional_tool.tool_stock_num == 0 and functional_tool.side_shelf_num == 0: - status = True - else: - status = True - if status: - knife_plan = self.env['sf.cam.work.order.program.knife.plan'].sudo().create({ - 'name': cnc_processing.workorder_id.production_id.name, - 'cam_procedure_code': cnc_processing.program_name, - 'filename': cnc_processing.cnc_id.name, - 'functional_tool_name': cnc_processing.cutting_tool_name, - 'cam_cutter_spacing_code': cnc_processing.cutting_tool_no, - 'process_type': cnc_processing.processing_type, - 'margin_x_y': float(cnc_processing.margin_x_y), - 'margin_z': float(cnc_processing.margin_z), - 'finish_depth': float(cnc_processing.depth_of_processing_z), - 'extension_length': float(cnc_processing.cutting_tool_extension_length), - 'shank_model': cnc_processing.cutting_tool_handle_type, - 'estimated_processing_time': cnc_processing.estimated_processing_time, - }) - logging.info('CAM工单程序用刀计划创建成功!!!') - # 创建装刀请求 - knife_plan.apply_for_tooling() - else: - logging.info('功能刀具【%s】满足CNC用刀需求!!!' % cnc_processing.cutting_tool_name) + for cnc_processing in cnc_processing_ids: + status = False + if cnc_processing.cutting_tool_name: + functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search( + [('name', '=', cnc_processing.cutting_tool_name)]) + if functional_tools: + for functional_tool in functional_tools: + if functional_tool.on_tool_stock_num == 0: + if functional_tool.tool_stock_num == 0 and functional_tool.side_shelf_num == 0: + status = True + else: + status = True + if status: + knife_plan = self.env['sf.cam.work.order.program.knife.plan'].sudo().create({ + 'name': cnc_processing.workorder_id.production_id.name, + 'cam_procedure_code': cnc_processing.program_name, + 'filename': cnc_processing.cnc_id.name, + 'functional_tool_name': cnc_processing.cutting_tool_name, + 'cam_cutter_spacing_code': cnc_processing.cutting_tool_no, + 'process_type': cnc_processing.processing_type, + 'margin_x_y': float(cnc_processing.margin_x_y), + 'margin_z': float(cnc_processing.margin_z), + 'finish_depth': float(cnc_processing.depth_of_processing_z), + 'extension_length': float(cnc_processing.cutting_tool_extension_length), + 'shank_model': cnc_processing.cutting_tool_handle_type, + 'estimated_processing_time': cnc_processing.estimated_processing_time, + }) + logging.info('CAM工单程序用刀计划创建成功!!!') + # 创建装刀请求 + knife_plan.apply_for_tooling() + else: + logging.info('功能刀具【%s】满足CNC用刀需求!!!' % cnc_processing.cutting_tool_name) def unlink_cam_plan(self, production): for item in production: