From 934b59d213e0d2c5fa9c40e873d330ed6733e8f9 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 14 May 2024 10:51:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9D=AF=E6=96=99=E6=96=B0=E5=A2=9E=E8=B7=AF?= =?UTF-8?q?=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_bf_connect/controllers/controllers.py | 7 +++--- sf_manufacturing/data/stock_data.xml | 23 +++++++++++++----- sf_manufacturing/models/mrp_production.py | 26 ++++++++++----------- sf_manufacturing/models/mrp_workorder.py | 1 + sf_manufacturing/models/product_template.py | 10 +++++--- sf_mrs_connect/controllers/controllers.py | 16 ++++++------- sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- sf_sale/views/sale_order_view.xml | 4 ++-- 9 files changed, 56 insertions(+), 39 deletions(-) diff --git a/sf_bf_connect/controllers/controllers.py b/sf_bf_connect/controllers/controllers.py index 4689345c..90c7e6c5 100644 --- a/sf_bf_connect/controllers/controllers.py +++ b/sf_bf_connect/controllers/controllers.py @@ -52,7 +52,7 @@ class Sf_Bf_Connect(http.Controller): self_machining_embryo = request.env['product.template'].sudo().no_bom_product_create( self_machining_id, item, - order_id, 'self_machining', i) + order_id, 'self_machining', i, product) # 创建坯料的bom self_machining_bom = request.env['mrp.bom'].with_user( request.env.ref("base.user_admin")).bom_create( @@ -78,7 +78,7 @@ class Sf_Bf_Connect(http.Controller): item, order_id, 'subcontract', - i) + i, product) if outsource_embryo == -3: res['status'] = -3 res['message'] = '该订单模型的材料型号在您分配的工厂里暂未设置获取方式和供应商,请先配置再进行分配' @@ -105,7 +105,8 @@ class Sf_Bf_Connect(http.Controller): purchase_embryo = request.env['product.template'].sudo().no_bom_product_create(purchase_id, item, order_id, - 'purchase', i) + 'purchase', i, + product) if purchase_embryo == -3: res['status'] = -3 res['message'] = '该订单模型的材料型号在您分配的工厂里暂未设置获取方式和供应商,请先配置再进行分配' diff --git a/sf_manufacturing/data/stock_data.xml b/sf_manufacturing/data/stock_data.xml index 72559691..3558e892 100644 --- a/sf_manufacturing/data/stock_data.xml +++ b/sf_manufacturing/data/stock_data.xml @@ -1,7 +1,7 @@ - + 工序编码规则 mrp.routing.workcenter 4 @@ -74,12 +74,23 @@ True 11 - + - - - - + + + + + + + + + + + + + + + diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index e3b83f21..354b47e1 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -304,21 +304,21 @@ class MrpProduction(models.Model): 'state': 'pending', }] if production.product_id.categ_id.type == '成品': - if production.product_id.id in product_id_to_production_names: + # if production.product_id.id in product_id_to_production_names: # 同一个产品多个制造订单对应一个编程单和模型库 # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递 - if not production.programming_no: - production_programming = self.search( - [('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)], - limit=1, order='id asc') - logging.info('production_programming1:%s' % production_programming.programming_no) - if not production_programming.programming_no: - production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id])) - else: - logging.info('production_programming2:%s' % production_programming.programming_no) - production.write({'programming_no': production_programming.programming_no, - 'programming_state': '编程中'}) - # 根据加工面板的面数及对应的工序模板生成工单 + # if not production.programming_no: + # production_programming = self.search( + # [('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)], + # limit=1, order='id asc') + # logging.info('production_programming1:%s' % production_programming.programming_no) + # if not production_programming.programming_no: + # production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id])) + # else: + # logging.info('production_programming2:%s' % production_programming.programming_no) + # production.write({'programming_no': production_programming.programming_no, + # 'programming_state': '编程中'}) + # # 根据加工面板的面数及对应的工序模板生成工单 i = 0 processing_panel_len = len(production.product_id.model_processing_panel.split(',')) for k in (production.product_id.model_processing_panel.split(',')): diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 87a5a87f..2214696c 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1040,6 +1040,7 @@ class CNCprocessing(models.Model): # 将FTP的nc文件下载到临时目录 def download_file_tmp(self, production_no, processing_panel): remotepath = os.path.join('/NC', production_no, 'return', processing_panel) + serverdir = os.path.join('/tmp', production_no, 'return', processing_panel) ftp_resconfig = self.env['res.config.settings'].get_values() ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'], ftp_resconfig['ftp_password']) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 3e91e6a3..8ab69366 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ 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): @@ -660,8 +660,12 @@ class ResProductMo(models.Model): return attachment # 创建坯料 - def no_bom_product_create(self, product_id, item, order_id, route_type, i): + def no_bom_product_create(self, product_id, item, order_id, route_type, i, finish_product): no_bom_copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy() + if finish_product.model_process_parameters_ids: + surface_technology = self.env['stock.rule'].sudo().search([('name', '=', '表面工艺外协')]) + if surface_technology: + no_bom_copy_product_id.route_ids |= surface_technology no_bom_copy_product_id.product_tmpl_id.active = True materials_id = self.env['sf.production.materials'].search( [('materials_no', '=', item['texture_code'])]) diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 4b45014a..12e22d01 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -37,14 +37,14 @@ class Sf_Mrs_Connect(http.Controller): # if ret['glb_file']: # cnc_production.glb_file = base64.b64encode(ret['glb_file']) # 拉取所有加工面的程序文件 - for r in ret['processing_panel']: - 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 == 0: - res['status'] = -2 - res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name) - return json.JSONEncoder().encode(res) + # for r in ret['processing_panel']: + # 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 == 0: + # res['status'] = -2 + # res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name) + # return json.JSONEncoder().encode(res) logging.info('创建cnc工单') program_path_tmp = os.path.join('/tmp', ret['folder_name'], 'return', r) # program_path_tmp = "C://Users//43484//Desktop//机企猫工作文档//其他//model_analysis" diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index 259655ee..775b901a 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 768c483c..241170a1 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/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index 8350c761..ba7543b7 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -198,7 +198,7 @@ - check_status desc,create_date asc + create_date desc False @@ -223,7 +223,7 @@ - date_order asc + create_date desc False