From 4b2e58a66d84951fa19e463c4db077224ceeaab7 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 22 Apr 2024 14:14:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=AE=A2=E5=8D=95=E5=8F=B7=E5=92=8C=E4=BA=BA?= =?UTF-8?q?=E5=B7=A5=E6=8A=A5=E4=BB=B7=E5=8F=8A=E6=B3=A8=E9=87=8A=E6=8E=89?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E9=95=BF=E5=AE=BD=E9=AB=98=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_sale/models/quick_easy_order_old.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 21fc3f5e..be9bae3d 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -128,18 +128,18 @@ class QuickEasyOrder(models.Model): # # print(volume) # item.model_volume = volume # # 长宽高/体积 - # output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(library_of_models.code) + '.stl') + # output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl') output_file = os.path.join('/tmp', str(model_code) + '.stl') - your_mesh = mesh.Mesh.from_file(output_file) - volume, cog, inertia = your_mesh.get_mass_properties() - xyz = (your_mesh.max_ - your_mesh.min_) - item.model_length = xyz[0] # 长 单位mm - item.model_width = xyz[1] # 宽 - item.model_height = xyz[2] # 高 - item.model_volume = volume + # your_mesh = mesh.Mesh.from_file(output_file) + # volume, cog, inertia = your_mesh.get_mass_properties() + # xyz = (your_mesh.max_ - your_mesh.min_) + # item.model_length = xyz[0] # 长 单位mm + # item.model_width = xyz[1] # 宽 + # item.model_height = xyz[2] # 高 + # item.model_volume = volume write_stl_file(shapes, output_file, 'binary', 0.03, 0.5) # 转化为glb - # output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(library_of_models.code) + '.glb') + # output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.glb') output_glb_file = os.path.join('/tmp', str(model_code) + '.glb') util_path = get_resource_path('sf_base', 'static/util') cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file) @@ -189,6 +189,7 @@ class QuickEasyOrder(models.Model): 'number': item.quantity, 'total_amount': item.price, 'remark': '', + 'manual_quotation': True, 'barcode': barcode }) # res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list']) @@ -292,7 +293,7 @@ class QuickEasyOrder(models.Model): 'model_height': order.model_height, 'model_volume': order.model_volume, 'color_model_path': '/tmp/' + str(model_code) + ".step", - 'model_order_no': order.name, + 'model_order_no': '%s-%s' % (order.name, 1), 'remark': '订单号:%s 客户:%s' % (order.name, order.customer_id.name) } try: From eb6607be00c1342a3984685d4988e255b31527c3 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 22 Apr 2024 14:27:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96cnc?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E6=96=B9=E6=B3=95=E5=85=B3=E4=BA=8E=E5=BF=AB?= =?UTF-8?q?=E9=80=9F=E8=AE=A2=E5=8D=95=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 4 +- sf_manufacturing/models/mrp_workorder.py | 41 ------------------- sf_manufacturing/views/mrp_workorder_view.xml | 12 +++--- 3 files changed, 8 insertions(+), 49 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 04b4d913..4b915392 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -135,7 +135,8 @@ class MrpProduction(models.Model): # cnc程序获取 def fetchCNC(self): cnc = self.env['mrp.production'].search([('id', '=', self.id)]) - quick_order = self.env['quick.easy.order'].search([('id', '=', cnc.product_id.id)]) + quick_order = self.env['quick.easy.order'].search( + [('name', '=', cnc.product_id.default_code.rsplit('-', 1)[0])]) programme_way = False if cnc.manual_quotation is True: programme_way = 'manual operation' @@ -157,7 +158,6 @@ class MrpProduction(models.Model): 'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height, 'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width, 'order_no': cnc.origin, - 'quick_order_no': quick_order.name if quick_order else False, 'model_order_no': cnc.product_id.default_code, 'user': cnc.env.user.name, 'programme_way': programme_way, diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 20369d9b..14471baf 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -652,47 +652,6 @@ class ResMrpWorkOrder(models.Model): else: self.results = '合格' - # cnc程序获取 - def fetchCNC(self): - try: - cnc = self.env['mrp.workorder'].search( - [('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1) - res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code, - 'production_no': self.production_id.name, - 'machine_tool_code': cnc.workcenter_id.equipment_id.code, - 'material_code': cnc.env['sf.production.materials'].search( - [('id', '=', cnc.product_id.materials_id.id)]).materials_no, - 'material_type_code': cnc.env['sf.materials.model'].search( - [('id', '=', cnc.product_id.materials_type_id.id)]).materials_no, - 'machining_processing_panel': cnc.product_id.model_processing_panel, - 'machining_precision': cnc.product_id.model_machining_precision, - 'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length, - 'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height, - 'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width, - 'order_no': cnc.production_id.origin, - 'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0], - 'user': self.env.user.name, - 'model_file': '' if not cnc.product_id.model_file else base64.b64encode( - cnc.product_id.model_file).decode('utf-8') - } - logging.info('res:%s' % res) - configsettings = self.env['res.config.settings'].get_values() - config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key']) - url = '/api/intelligent_programming/create' - config_url = configsettings['sf_url'] + url - # res_str = json.dumps(res) - ret = requests.post(config_url, json={}, data=res, headers=config_header) - ret = ret.json() - logging.info('fetchCNC-ret:%s' % ret) - if ret['status'] == 1: - self.write( - {'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'}) - else: - raise UserError(ret['message']) - except Exception as e: - logging.info('fetchCNC error:%s' % e) - raise UserError("cnc程序获取编程单失败,请联系管理员") - def json_workorder_str1(self, k, production, route): workorders_values_str = [0, '', { 'product_uom_id': production.product_uom_id.id, diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index f3e2faef..65fbd973 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -210,12 +210,12 @@ - -
-
-
+ + + + + +