From 9218633a5ef828d7a8cf0b9873f5e42274f39b4a Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 23 Aug 2024 17:32:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A1=A8=E9=9D=A2=E5=B7=A5?= =?UTF-8?q?=E8=89=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/__manifest__.py | 2 +- sf_base/models/common.py | 1 + sf_base/models/tool_base_new.py.rej | 10 --- sf_manufacturing/models/mrp_production.py | 17 ++-- sf_manufacturing/models/product_template.py | 4 +- sf_mrs_connect/controllers/controllers.py | 96 ++++++++++----------- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- sf_sale/models/sale_order.py | 1 + 9 files changed, 64 insertions(+), 75 deletions(-) delete mode 100644 sf_base/models/tool_base_new.py.rej diff --git a/sf_base/__manifest__.py b/sf_base/__manifest__.py index b10c2630..3c5175f0 100644 --- a/sf_base/__manifest__.py +++ b/sf_base/__manifest__.py @@ -23,7 +23,7 @@ 'views/tool_basic_param.xml', 'views/tool_menu.xml', 'views/menu_fixture_view.xml', - 'views/change_base_view.xml', + # 'views/change_base_view.xml', 'views/Printer.xml', ], diff --git a/sf_base/models/common.py b/sf_base/models/common.py index 65dfe13d..e8019d87 100644 --- a/sf_base/models/common.py +++ b/sf_base/models/common.py @@ -88,6 +88,7 @@ class MrsProductionProcess(models.Model): code = fields.Char("编码") name = fields.Char('名称') remark = fields.Text("备注") + sequence = fields.Integer('排序') # processing_order_ids = fields.One2many('sf.processing.order', 'production_process_id', string='工序') partner_process_ids = fields.Many2many('res.partner', 'process_ids', '加工工厂') active = fields.Boolean('有效', default=True) diff --git a/sf_base/models/tool_base_new.py.rej b/sf_base/models/tool_base_new.py.rej deleted file mode 100644 index 6db1f28a..00000000 --- a/sf_base/models/tool_base_new.py.rej +++ /dev/null @@ -1,10 +0,0 @@ -diff a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py (rejected hunks) -@@ -108,6 +108,4 @@ - cutting_speed_ids = fields.One2many('sf.cutting.speed', 'standard_library_id', string='切削速度Vc') -- feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', -- domain=[('cutting_speed', '!=', False)]) -- feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', -- domain=[('cutting_speed', '!=', False)]) -+ feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz') -+ feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz') - diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 8e1f7199..a17c05b7 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -455,19 +455,16 @@ class MrpProduction(models.Model): surface_technics_arr.append(item.route_workcenter_id.surface_technics_id.id) route_workcenter_arr.append(item.route_workcenter_id.id) if surface_technics_arr: - production_process_category = self.env['sf.production.process.category'].search( - [('production_process_ids.id', 'in', surface_technics_arr)], + production_process = self.env['sf.production.process'].search( + [('parameter_ids.id', 'in', surface_technics_arr)], order='sequence asc' ) - # 用filter刷选表面工艺id'是否存在工艺类别对象里 - if production_process_category: - for p in production_process_category: - logging.info('production_process_category:%s' % p.name) - production_process = p.production_process_ids.filtered( - lambda pp: pp.id in surface_technics_arr) + if production_process: + for p in production_process: + logging.info('production_process:%s' % p.name) if production_process: process_parameter = production.product_id.model_process_parameters_ids.filtered( - lambda pm: pm.process_id.id == production_process.id) + lambda pm: pm.process_id.id == p.id) if process_parameter: # 产品为表面工艺服务的供应商 product_production_process = self.env['product.template'].search( @@ -475,7 +472,7 @@ class MrpProduction(models.Model): if product_production_process: route_production_process = self.env[ 'mrp.routing.workcenter'].search( - [('surface_technics_id', '=', production_process.id), + [('surface_technics_id', '=', p.id), ('id', 'in', route_workcenter_arr)]) if route_production_process: workorders_values.append( diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 071f1167..37fa02bd 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError 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_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index ce342d4a..5da16d95 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -9,7 +9,7 @@ from odoo.http import request class Sf_Mrs_Connect(http.Controller): - @http.route('/api/cnc_processing/create', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False, + @http.route('/api/cnc_processing/create', type='json', auth='none', methods=['GET', 'POST'], csrf=False, cors="*") def get_cnc_processing_create(self, **kw): """ @@ -29,21 +29,21 @@ class Sf_Mrs_Connect(http.Controller): [('programming_no', '=', ret['programming_no'])]) 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'] @@ -82,38 +82,38 @@ class Sf_Mrs_Connect(http.Controller): # if pre_workorder: # pre_workorder.write( # {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) - 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', - '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', - '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': '已编程'}) - cnc_program_ids = [item.id for item in productions] - workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( - [('production_id', 'in', cnc_program_ids)]) - if workpiece_delivery: - workpiece_delivery.write( - {'is_cnc_program_down': True, 'production_line_id': productions.production_line_id.id}) + # 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', + # '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', + # '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': '已编程'}) + # cnc_program_ids = [item.id for item in productions] + # workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( + # [('production_id', 'in', cnc_program_ids)]) + # if workpiece_delivery: + # workpiece_delivery.write( + # {'is_cnc_program_down': True, 'production_line_id': productions.production_line_id.id}) return json.JSONEncoder().encode(res) else: res = {'status': 0, 'message': '该制造订单暂未开始'} diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index 081807a4..cb1886a1 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -8,8 +8,8 @@ from datetime import datetime import requests from odoo import http from odoo.http import request -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 from odoo import models, fields, api from odoo.modules import get_resource_path from odoo.exceptions import ValidationError, UserError diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 3ae65db3..92f6cda2 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -6,8 +6,8 @@ import os from datetime import datetime from stl import mesh # from OCC.Core.GProp import GProp_GProps -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 from odoo.addons.sf_base.commons.common import Common from odoo import models, fields, api from odoo.modules import get_resource_path diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 348d6c79..4f26a4a5 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -299,6 +299,7 @@ class ResPartnerToSale(models.Model): _inherit = 'res.partner' purchase_user_id = fields.Many2one('res.users', '采购员') + translated_display_name = fields.Char('2') @api.constrains('name') def _check_name(self):