diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 6624e709..33939c72 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -242,7 +242,7 @@ class Manufacturing_Connect(http.Controller): logging.info('button_Work_End error:%s' % e) return json.JSONEncoder().encode(res) - @http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False, + @http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='none', methods=['GET', 'POST'], csrf=False, cors="*") def PartQualityInspect(self, **kw): """ diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index ae523bd9..88ca4c2c 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -763,11 +763,7 @@ class MrpProduction(models.Model): 'default_production_id': self.id, 'default_reprogramming_num': cloud_programming['reprogramming_num'], 'default_programming_state': cloud_programming['programming_state'], - 'default_is_reprogramming': False if (cloud_programming['programming_state'] in ['编程中', - '待编程'] and self.programming_state in [ - '编程中', '已编程']) - or (cloud_programming['programming_state'] in [ - '已编程'] and self.programming_state in ['已编程未下发']) else True + 'default_is_reprogramming': False if cloud_programming['programming_state'] not in ['已下发'] else True } } @@ -802,7 +798,7 @@ class MrpProduction(models.Model): 'pending'] and m1.processing_panel == rework_item.processing_panel and m1.routing_type == 'CNC加工') if not pending_workorder.cnc_ids: production.get_new_program(rework_item.processing_panel) - production.write({'state': 'progress', 'programming_state': '已编程', 'is_rework': False}) + # production.write({'state': 'progress', 'programming_state': '已编程', 'is_rework': False}) productions_not_delivered.write({'programming_state': '已编程', 'is_rework': False}) # 从cloud获取重新编程过的最新程序 @@ -817,17 +813,17 @@ class MrpProduction(models.Model): r = r.json() result = json.loads(r['result']) if result['status'] == 1: - # program_path_tmp_panel = os.path.join('/tmp', result['folder_name'], 'return', processing_panel) - # if os.path.exists(program_path_tmp_panel): - # files_r = os.listdir(program_path_tmp_panel) - # if files_r: - # for file_name in files_r: - # file_path = os.path.join(program_path_tmp_panel, file_name) - # os.remove(file_path) - # download_state = self.env['sf.cnc.processing'].download_file_tmp(result['folder_name'], - # processing_panel) - # if download_state is False: - # raise UserError('编程单号为%s的CNC程序文件从FTP拉取失败' % (self.programming_no)) + program_path_tmp_panel = os.path.join('/tmp', result['folder_name'], 'return', processing_panel) + if os.path.exists(program_path_tmp_panel): + files_r = os.listdir(program_path_tmp_panel) + if files_r: + for file_name in files_r: + file_path = os.path.join(program_path_tmp_panel, file_name) + os.remove(file_path) + download_state = self.env['sf.cnc.processing'].download_file_tmp(result['folder_name'], + processing_panel) + if download_state is False: + raise UserError('编程单号为%s的CNC程序文件从FTP拉取失败' % (self.programming_no)) productions = self.env['mrp.production'].search( [('programming_no', '=', self.programming_no), ('state', 'not in', ('cancel', 'done'))]) if productions: @@ -841,8 +837,8 @@ class MrpProduction(models.Model): panel_workorder.cnc_ids.sudo().unlink() self.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( productions) - program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', - processing_panel) + # 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) files_panel = os.listdir(program_path_tmp_panel) if files_panel: diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 6ffdb0cb..e8458d29 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -729,11 +729,12 @@ class ResMrpWorkOrder(models.Model): cnc_workorder = self.env['mrp.workorder'].search( [('production_id', '=', workorder.production_id.id), ('processing_panel', '=', workorder.processing_panel), - ('routing_type', '=', 'CNC加工'), ('state', '=', 'done'), + ('routing_type', '=', 'CNC加工'), ('state', 'in', ['done', 'rework']), ('test_results', '=', '返工')]) if workorder.state not in ['cancel', 'progress', 'rework']: if workorder.production_id.state == 'rework': logging.info('len(re_work):%s' % len(re_work)) + logging.info('len(cnc_workorder):%s' % len(cnc_workorder)) logging.info('工序:%s' % workorder.routing_type) logging.info('状态:%s' % workorder.state) logging.info('is_rework:%s' % workorder.is_rework) @@ -771,6 +772,7 @@ class ResMrpWorkOrder(models.Model): # workorder.state = 'waiting' elif workorder.production_id.state == 'progress': logging.info('len(re_work):%s' % len(re_work)) + logging.info('len(cnc_workorder):%s' % len(cnc_workorder)) logging.info('工序:%s' % workorder.routing_type) logging.info('状态:%s' % workorder.state) logging.info('is_rework:%s' % workorder.is_rework) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index f292d694..4d05de81 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -7,8 +7,8 @@ import os from odoo import models, fields, api, _ from odoo.exceptions import ValidationError from odoo.modules import get_resource_path -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_manufacturing/wizard/rework_wizard_views.xml b/sf_manufacturing/wizard/rework_wizard_views.xml index 524bb8ae..49274368 100644 --- a/sf_manufacturing/wizard/rework_wizard_views.xml +++ b/sf_manufacturing/wizard/rework_wizard_views.xml @@ -20,13 +20,13 @@ style='color:red;'/>次,且当前编程状态为 + decoration-danger="programming_state =='已编程'" readonly="1"/> + attrs='{"invisible": [("routing_type","in",["装夹预调","CNC加工"])],"readonly": [("is_reprogramming","=",False)]}'/>