From 001b2ead571ef1c88f199f6e8257ee1894515a59 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Wed, 24 Jul 2024 16:20:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E6=9B=B4=E5=85=B7=E5=88=B6?= =?UTF-8?q?=E9=80=A0=E8=AE=A2=E5=8D=95=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=8F=98=E6=9B=B4=E7=AC=AC=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E8=A3=85=E5=A4=B9=E9=A2=84=E8=B0=83=E5=B7=A5=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 2d8ecfb5..520af4f4 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -777,6 +777,8 @@ class ResMrpWorkOrder(models.Model): if workorder.production_id.is_rework is True: if re_work or cnc_workorder: workorder.state = 'waiting' + if workorder.production_id.tool_state in ['1', '2'] and workorder.state != 'pending': + workorder.state = 'waiting' elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'rework', 'cancel']: pre_workorder = self.env['mrp.workorder'].search( From 44a9ad340b6b839badcc7d0783562e8884bec5a8 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 24 Jul 2024 16:39:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 960d4b14..749ceafe 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -868,17 +868,25 @@ class MrpProduction(models.Model): raise UserError('编程单号为%s的CNC程序文件从FTP拉取失败' % (self.programming_no)) productions = self.env['mrp.production'].search( [('programming_no', '=', self.programming_no), ('state', 'not in', ('cancel', 'done'))]) + logging.info('get_new_program productions:%s' % productions) if productions: - panel_workorder = productions.workorder_ids.filtered( - lambda - ac: ac.processing_panel == processing_panel and ac.routing_type == 'CNC加工' and ac.state not in ( - 'rework', 'done')) + workorder_ids = set() + for production in productions: + for workorder in production.workorder_ids: + if workorder.processing_panel == processing_panel and workorder.routing_type == 'CNC加工' and workorder.state not in ( + 'rework', 'done'): + workorder_ids.add(workorder.id) + panel_workorder = self.env['mrp.workorder'].search([('id', 'in', list(workorder_ids))]) + logging.info('get_new_program panel_workorder:%s' % panel_workorder) if panel_workorder: if panel_workorder.cnc_ids: + logging.info('get_new_program 1') panel_workorder.cmm_ids.sudo().unlink() panel_workorder.cnc_ids.sudo().unlink() + logging.info('get_new_program 2') self.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( productions) + logging.info('get_new_program 3') # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', # processing_panel) logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) @@ -889,15 +897,19 @@ class MrpProduction(models.Model): if file_extension.lower() == '.pdf': panel_file_path = os.path.join(program_path_tmp_panel, file) logging.info('panel_file_path:%s' % panel_file_path) + logging.info('get_new_program 4') panel_workorder.write( {'cnc_ids': panel_workorder.cnc_ids.sudo()._json_cnc_processing(processing_panel, 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('get_new_program 5') pre_workorder = productions.workorder_ids.filtered(lambda ap: ap.routing_type == '装夹预调' and ap.processing_panel == processing_panel and ap.state != 'rework') + logging.info('get_new_program 6') if pre_workorder: pre_workorder.write( {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) + logging.info('get_new_program 7') else: raise UserError(result['message']) except Exception as e: