From 40f327ea1745437cdf1dac3844c5f078c0146662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Tue, 10 Sep 2024 16:13:57 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E4=BB=B6?= =?UTF-8?q?=E6=8B=86=E5=8D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 6 +- sf_manufacturing/models/agv_scheduling.py | 1 + sf_manufacturing/models/mrp_workorder.py | 38 +++--- .../wizard/workpiece_delivery_wizard.py | 16 ++- sf_mrs_connect/controllers/controllers.py | 112 +++++++++--------- 5 files changed, 91 insertions(+), 82 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 632e9e4c..c249eda2 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -477,7 +477,7 @@ class Manufacturing_Connect(http.Controller): logging.info('LocationChange error:%s' % e) return json.JSONEncoder().encode(res) - @http.route('/AutoDeviceApi/AGVToProduct', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False, + @http.route('/AutoDeviceApi/AGVToProduct', type='json', auth='public', methods=['GET', 'POST'], csrf=False, cors="*") def AGVToProduct(self, **kw): """ @@ -549,7 +549,7 @@ class Manufacturing_Connect(http.Controller): logging.info('AGVToProduct error:%s' % e) return json.JSONEncoder().encode(res) - @http.route('/AutoDeviceApi/AGVDownProduct', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False, + @http.route('/AutoDeviceApi/AGVDownProduct', type='json', auth='public', methods=['GET', 'POST'], csrf=False, cors="*") def AGVDownProduct(self, **kw): """ @@ -668,7 +668,7 @@ class Manufacturing_Connect(http.Controller): logging.info('AGVDownProduct error:%s' % e) return json.JSONEncoder().encode(res) - @http.route('/AutoDeviceApi/AgvStationState', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False, + @http.route('/AutoDeviceApi/AgvStationState', type='json', auth='public', methods=['GET', 'POST'], csrf=False, cors="*") def AGVStationState(self, **kw): """ diff --git a/sf_manufacturing/models/agv_scheduling.py b/sf_manufacturing/models/agv_scheduling.py index 488fa0a0..f758abd9 100644 --- a/sf_manufacturing/models/agv_scheduling.py +++ b/sf_manufacturing/models/agv_scheduling.py @@ -270,6 +270,7 @@ class ResMrpWorkOrder(models.Model): """ 获取关联的制造订单下产线的agv任务 """ + self.ensure_one() workorder_ids = self.production_id.workorder_ids cnc_workorder = workorder_ids.filtered( lambda w: w.routing_type == 'CNC加工' and w.state == 'done' and w.processing_panel == self.processing_panel diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 976097e3..28f10ab4 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1351,23 +1351,23 @@ class ResMrpWorkOrder(models.Model): return res def button_delivery(self): - production_ids = [] - workorder_ids = [] + # production_ids = [] + # workorder_ids = [] delivery_type = '运送空料架' - max_num = 4 # 最大配送数量 - feeder_station_start_id = False - if len(self) > max_num: - raise UserError('仅限于拆卸1-4个制造订单,请重新选择') - for item in self: - if item.state != 'ready': - raise UserError('请选择状态为【就绪】的工单进行解除装夹') - - production_ids.append(item.production_id.id) - workorder_ids.append(item.id) - if not feeder_station_start_id: - down_product_agv_scheduling = self.get_down_product_agv_scheduling() - if down_product_agv_scheduling: - feeder_station_start_id = down_product_agv_scheduling.end_site_id.id + # max_num = 4 # 最大配送数量 + # feeder_station_start_id = False + # if len(self) > max_num: + # raise UserError('仅限于拆卸1-4个制造订单,请重新选择') + # for item in self: + # if item.state != 'ready': + # raise UserError('请选择状态为【就绪】的工单进行解除装夹') + # + # production_ids.append(item.production_id.id) + # workorder_ids.append(item.id) + # if not feeder_station_start_id: + # down_product_agv_scheduling = item.get_down_product_agv_scheduling() + # if down_product_agv_scheduling: + # feeder_station_start_id = down_product_agv_scheduling.end_site_id.id return { 'name': _('确认'), 'type': 'ir.actions.act_window', @@ -1376,12 +1376,12 @@ class ResMrpWorkOrder(models.Model): 'target': 'new', 'context': { # 'default_delivery_ids': [(6, 0, delivery_ids)], - 'default_production_ids': [(6, 0, production_ids)], + # 'default_production_ids': [(6, 0, production_ids)], 'default_delivery_type': delivery_type, - 'default_workorder_ids': [(6, 0, workorder_ids)], + # 'default_workorder_ids': [(6, 0, workorder_ids)], 'default_workcenter_id': self.env.context.get('default_workcenter_id'), 'default_confirm_button': '确认解除', - 'default_feeder_station_start_id': feeder_station_start_id, + # 'default_feeder_station_start_id': feeder_station_start_id, }} diff --git a/sf_manufacturing/wizard/workpiece_delivery_wizard.py b/sf_manufacturing/wizard/workpiece_delivery_wizard.py index f00ac499..4645d45f 100644 --- a/sf_manufacturing/wizard/workpiece_delivery_wizard.py +++ b/sf_manufacturing/wizard/workpiece_delivery_wizard.py @@ -185,7 +185,11 @@ class WorkpieceDeliveryWizard(models.TransientModel): # 判断是否是AGV接驳站名称 agv_site = self.env['sf.agv.site'].search([('name', '=', barcode)]) if agv_site: - self.feeder_station_start_id = agv_site.id + if not self.feeder_station_start_id: + self.feeder_station_start_id = agv_site.id + else: + if self.feeder_station_start_id.id != agv_site.id: + raise UserError('接驳站不匹配!') return delivery_type = self.env.context.get('default_delivery_type') if delivery_type == '上产线': @@ -211,10 +215,14 @@ class WorkpieceDeliveryWizard(models.TransientModel): self.production_ids |= workorder.production_id self.workorder_ids |= workorder - if not self.feeder_station_start_id: - down_product_agv_scheduling = self.get_down_product_agv_scheduling() - if down_product_agv_scheduling: + down_product_agv_scheduling = self.get_down_product_agv_scheduling() + if down_product_agv_scheduling: + if not self.feeder_station_start_id: self.feeder_station_start_id = down_product_agv_scheduling.end_site_id.id + else: + if self.feeder_station_start_id.id != down_product_agv_scheduling.end_site_id.id: + raise UserError('该rfid不在%s接驳站内', self.feeder_station_start_id.name) + else: raise UserError('该rfid码对应的工单不存在') return diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index c5d1cd10..25736199 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -31,67 +31,67 @@ class Sf_Mrs_Connect(http.Controller): request.env.ref("base.user_admin")).search(domain) if productions: # 拉取所有加工面的程序文件 - for r in ret['processing_panel'].split(','): - program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) - if os.path.exists(program_path_tmp_r): - files_r = os.listdir(program_path_tmp_r) - if files_r: - for file_name in files_r: - file_path = os.path.join(program_path_tmp_r, file_name) - os.remove(file_path) - download_state = request.env['sf.cnc.processing'].with_user( - request.env.ref("base.user_admin")).download_file_tmp( - ret['folder_name'], r) - if download_state is False: - res['status'] = -2 - res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) - return json.JSONEncoder().encode(res) + # for r in ret['processing_panel'].split(','): + # program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) + # if os.path.exists(program_path_tmp_r): + # files_r = os.listdir(program_path_tmp_r) + # if files_r: + # for file_name in files_r: + # file_path = os.path.join(program_path_tmp_r, file_name) + # os.remove(file_path) + # download_state = request.env['sf.cnc.processing'].with_user( + # request.env.ref("base.user_admin")).download_file_tmp( + # ret['folder_name'], r) + # if download_state is False: + # res['status'] = -2 + # res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) + # return json.JSONEncoder().encode(res) for production in productions: if not production.workorder_ids: production.product_id.model_processing_panel = ret['processing_panel'] production._create_workorder(ret) productions.process_range_time() - else: - for panel in ret['processing_panel'].split(','): - # 查询状态为进行中且工序类型为CNC加工的工单 - cnc_workorder_has = production.workorder_ids.filtered( - lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', - 'rework', - 'cancel'] and ach.processing_panel == panel) - if cnc_workorder_has: - if cnc_workorder_has.cnc_ids: - cnc_workorder_has.cmm_ids.sudo().unlink() - cnc_workorder_has.cnc_ids.sudo().unlink() - request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( - production) - cnc_workorder_has.write( - {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret), - 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)}) - for panel in ret['processing_panel'].split(','): - # 查询状态为进行中且工序类型为CNC加工的工单 - cnc_workorder = productions.workorder_ids.filtered( - lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' - 'cancel'] and ac.processing_panel == panel) - if cnc_workorder: - # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', - # panel) - program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) - logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) - files_panel = os.listdir(program_path_tmp_panel) - if files_panel: - for file in files_panel: - file_extension = os.path.splitext(file)[1] - logging.info('file_extension:%s' % file_extension) - 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) - cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) - pre_workorder = productions.workorder_ids.filtered( - lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' - 'cancel'] and ap.processing_panel == panel) - if pre_workorder: - pre_workorder.write( - {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) + # else: + # for panel in ret['processing_panel'].split(','): + # # 查询状态为进行中且工序类型为CNC加工的工单 + # cnc_workorder_has = production.workorder_ids.filtered( + # lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', + # 'rework', + # 'cancel'] and ach.processing_panel == panel) + # if cnc_workorder_has: + # if cnc_workorder_has.cnc_ids: + # cnc_workorder_has.cmm_ids.sudo().unlink() + # cnc_workorder_has.cnc_ids.sudo().unlink() + # request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( + # production) + # cnc_workorder_has.write( + # {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret), + # 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)}) + # for panel in ret['processing_panel'].split(','): + # # 查询状态为进行中且工序类型为CNC加工的工单 + # cnc_workorder = productions.workorder_ids.filtered( + # lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' + # 'cancel'] and ac.processing_panel == panel) + # if cnc_workorder: + # # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', + # # panel) + # program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) + # logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) + # files_panel = os.listdir(program_path_tmp_panel) + # if files_panel: + # for file in files_panel: + # file_extension = os.path.splitext(file)[1] + # logging.info('file_extension:%s' % file_extension) + # 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) + # cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) + # pre_workorder = productions.workorder_ids.filtered( + # lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' + # 'cancel'] and ap.processing_panel == panel) + # if pre_workorder: + # pre_workorder.write( + # {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) productions.write({'programming_state': '已编程', 'work_state': '已编程'}) return json.JSONEncoder().encode(res) else: From d000aa095f9f4a012ef80a9c9032fc0769f712ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Tue, 10 Sep 2024 17:49:52 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=AF=B9=E4=BA=8E=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E8=BF=9B=E8=A1=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wizard/workpiece_delivery_views.xml | 4 +-- .../wizard/workpiece_delivery_wizard.py | 33 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/sf_manufacturing/wizard/workpiece_delivery_views.xml b/sf_manufacturing/wizard/workpiece_delivery_views.xml index 699fff53..e895d39e 100644 --- a/sf_manufacturing/wizard/workpiece_delivery_views.xml +++ b/sf_manufacturing/wizard/workpiece_delivery_views.xml @@ -18,8 +18,8 @@
-
diff --git a/sf_manufacturing/wizard/workpiece_delivery_wizard.py b/sf_manufacturing/wizard/workpiece_delivery_wizard.py index 4645d45f..a84612ff 100644 --- a/sf_manufacturing/wizard/workpiece_delivery_wizard.py +++ b/sf_manufacturing/wizard/workpiece_delivery_wizard.py @@ -87,21 +87,9 @@ class WorkpieceDeliveryWizard(models.TransientModel): } def confirm(self): try: - # if self.workorder_id: - # self.workorder_id.workpiece_delivery_ids[0].agv_scheduling_id() - # else: - # is_not_production_line = 0 - # same_production_line_id = None - # notsame_production_line_arr = [] - # for item in self.production_ids: - # if same_production_line_id is None: - # same_production_line_id = item.production_line_id.id - # if item.production_line_id.id != same_production_line_id: - # notsame_production_line_arr.append(item.name) - # notsame_production_line_str = ','.join(map(str, notsame_production_line_arr)) - # if is_not_production_line >= 1: - # raise UserError('制造订单号为%s的目的生产线不一致' % notsame_production_line_str) - # else: + if not self.workorder_ids: + raise UserError('制造订单不能为空') + scheduling = self.env['sf.agv.scheduling'].add_scheduling( agv_start_site_name=self.feeder_station_start_id.name, agv_route_type=self.delivery_type, @@ -129,7 +117,18 @@ class WorkpieceDeliveryWizard(models.TransientModel): item.button_start() item.button_finish() - return scheduling.read()[0] + # return scheduling.read()[0] + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'target': 'new', + 'params': { + 'message': '任务下发成功!AGV任务调度编号为【%s】' % scheduling.name, + 'type': 'success', + 'sticky': False, + 'next': {'type': 'ir.actions.act_window_close'}, + } + } except Exception as e: logging.info('%s任务下发失败:%s' % (self.delivery_type, e)) raise UserError('%s任务下发失败:%s' % (self.delivery_type, e)) @@ -189,7 +188,7 @@ class WorkpieceDeliveryWizard(models.TransientModel): self.feeder_station_start_id = agv_site.id else: if self.feeder_station_start_id.id != agv_site.id: - raise UserError('接驳站不匹配!') + raise UserError('起点接驳站不匹配!') return delivery_type = self.env.context.get('default_delivery_type') if delivery_type == '上产线': From 9a3404f4b8575d845c7a9831145038882c7337b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Tue, 10 Sep 2024 17:51:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_mrs_connect/controllers/controllers.py | 112 +++++++++++----------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 25736199..c5d1cd10 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -31,67 +31,67 @@ class Sf_Mrs_Connect(http.Controller): request.env.ref("base.user_admin")).search(domain) if productions: # 拉取所有加工面的程序文件 - # for r in ret['processing_panel'].split(','): - # program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) - # if os.path.exists(program_path_tmp_r): - # files_r = os.listdir(program_path_tmp_r) - # if files_r: - # for file_name in files_r: - # file_path = os.path.join(program_path_tmp_r, file_name) - # os.remove(file_path) - # download_state = request.env['sf.cnc.processing'].with_user( - # request.env.ref("base.user_admin")).download_file_tmp( - # ret['folder_name'], r) - # if download_state is False: - # res['status'] = -2 - # res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) - # return json.JSONEncoder().encode(res) + for r in ret['processing_panel'].split(','): + program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) + if os.path.exists(program_path_tmp_r): + files_r = os.listdir(program_path_tmp_r) + if files_r: + for file_name in files_r: + file_path = os.path.join(program_path_tmp_r, file_name) + os.remove(file_path) + download_state = request.env['sf.cnc.processing'].with_user( + request.env.ref("base.user_admin")).download_file_tmp( + ret['folder_name'], r) + if download_state is False: + res['status'] = -2 + res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) + return json.JSONEncoder().encode(res) for production in productions: if not production.workorder_ids: production.product_id.model_processing_panel = ret['processing_panel'] production._create_workorder(ret) productions.process_range_time() - # else: - # for panel in ret['processing_panel'].split(','): - # # 查询状态为进行中且工序类型为CNC加工的工单 - # cnc_workorder_has = production.workorder_ids.filtered( - # lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', - # 'rework', - # 'cancel'] and ach.processing_panel == panel) - # if cnc_workorder_has: - # if cnc_workorder_has.cnc_ids: - # cnc_workorder_has.cmm_ids.sudo().unlink() - # cnc_workorder_has.cnc_ids.sudo().unlink() - # request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( - # production) - # cnc_workorder_has.write( - # {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret), - # 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)}) - # for panel in ret['processing_panel'].split(','): - # # 查询状态为进行中且工序类型为CNC加工的工单 - # cnc_workorder = productions.workorder_ids.filtered( - # lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' - # 'cancel'] and ac.processing_panel == panel) - # if cnc_workorder: - # # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', - # # panel) - # program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) - # logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) - # files_panel = os.listdir(program_path_tmp_panel) - # if files_panel: - # for file in files_panel: - # file_extension = os.path.splitext(file)[1] - # logging.info('file_extension:%s' % file_extension) - # 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) - # cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) - # pre_workorder = productions.workorder_ids.filtered( - # lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' - # 'cancel'] and ap.processing_panel == panel) - # if pre_workorder: - # pre_workorder.write( - # {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) + else: + for panel in ret['processing_panel'].split(','): + # 查询状态为进行中且工序类型为CNC加工的工单 + cnc_workorder_has = production.workorder_ids.filtered( + lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', + 'rework', + 'cancel'] and ach.processing_panel == panel) + if cnc_workorder_has: + if cnc_workorder_has.cnc_ids: + cnc_workorder_has.cmm_ids.sudo().unlink() + cnc_workorder_has.cnc_ids.sudo().unlink() + request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( + production) + cnc_workorder_has.write( + {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret), + 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)}) + for panel in ret['processing_panel'].split(','): + # 查询状态为进行中且工序类型为CNC加工的工单 + cnc_workorder = productions.workorder_ids.filtered( + lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' + 'cancel'] and ac.processing_panel == panel) + if cnc_workorder: + # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', + # panel) + program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) + logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) + files_panel = os.listdir(program_path_tmp_panel) + if files_panel: + for file in files_panel: + file_extension = os.path.splitext(file)[1] + logging.info('file_extension:%s' % file_extension) + 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) + cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) + pre_workorder = productions.workorder_ids.filtered( + lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' + 'cancel'] and ap.processing_panel == panel) + if pre_workorder: + pre_workorder.write( + {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) productions.write({'programming_state': '已编程', 'work_state': '已编程'}) return json.JSONEncoder().encode(res) else: From b188c8adfeaf5e4f46a0f50bc7d898a6bb418853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 11 Sep 2024 09:14:00 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wizard/workpiece_delivery_wizard.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sf_manufacturing/wizard/workpiece_delivery_wizard.py b/sf_manufacturing/wizard/workpiece_delivery_wizard.py index a84612ff..4ee0928c 100644 --- a/sf_manufacturing/wizard/workpiece_delivery_wizard.py +++ b/sf_manufacturing/wizard/workpiece_delivery_wizard.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- # Part of YiZuo. See LICENSE file for full copyright and licensing details. -import json import logging -from odoo.exceptions import UserError, ValidationError from datetime import datetime, date +from odoo.exceptions import UserError from odoo import models, api, fields @@ -79,12 +78,13 @@ class WorkpieceDeliveryWizard(models.TransientModel): 'tag': 'display_notification', 'target': 'new', 'params': { - 'message': '任务下发成功!AGV任务调度编号为【%s】' % scheduling['name'], + 'message': f'任务下发成功!AGV任务调度编号为【{scheduling["name"]}】', 'type': 'success', 'sticky': False, 'next': {'type': 'ir.actions.act_window_close'}, } } + def confirm(self): try: if not self.workorder_ids: @@ -123,15 +123,15 @@ class WorkpieceDeliveryWizard(models.TransientModel): 'tag': 'display_notification', 'target': 'new', 'params': { - 'message': '任务下发成功!AGV任务调度编号为【%s】' % scheduling.name, + 'message': f'任务下发成功!AGV任务调度编号为【{scheduling.name}】', 'type': 'success', 'sticky': False, 'next': {'type': 'ir.actions.act_window_close'}, } } except Exception as e: - logging.info('%s任务下发失败:%s' % (self.delivery_type, e)) - raise UserError('%s任务下发失败:%s' % (self.delivery_type, e)) + logging.info('%s任务下发失败:%s', self.delivery_type, e) + raise UserError(f'{self.delivery_type}任务下发失败:{e}') from e # def recognize_production(self): # # production_ids = [] @@ -208,7 +208,7 @@ class WorkpieceDeliveryWizard(models.TransientModel): if workorder: if (len(self.production_ids) > 0 and workorder.production_line_id.id != self.production_ids[0].production_line_id.id): - raise UserError('该rfid对应的制造订单号为%s的目的生产线不一致' % workorder.production_id.name) + raise UserError(f'该rfid对应的制造订单号为{workorder.production_id.name}的目的生产线不一致') # 将对象添加到对应的同模型且是多对多类型里 self.production_ids |= workorder.production_id @@ -220,7 +220,7 @@ class WorkpieceDeliveryWizard(models.TransientModel): self.feeder_station_start_id = down_product_agv_scheduling.end_site_id.id else: if self.feeder_station_start_id.id != down_product_agv_scheduling.end_site_id.id: - raise UserError('该rfid不在%s接驳站内', self.feeder_station_start_id.name) + raise UserError(f'该rfid不在{self.feeder_station_start_id.name}接驳站内') else: raise UserError('该rfid码对应的工单不存在')