新增调取cloud的刀具标准库接口
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
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 odoo.addons.sf_base.commons.common import Common
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
import logging
|
||||
import base64
|
||||
import hashlib
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
class ResProductMo(models.Model):
|
||||
@@ -62,6 +65,8 @@ class ResProductMo(models.Model):
|
||||
|
||||
cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='型号',
|
||||
)
|
||||
|
||||
cutting_tool_model = fields.Char('型号')
|
||||
cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='类型',
|
||||
domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]")
|
||||
|
||||
@@ -104,7 +109,6 @@ class ResProductMo(models.Model):
|
||||
suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'rel_coolant_product_template',
|
||||
'适合冷却液', domain=[('type', '=', '冷却液')])
|
||||
|
||||
|
||||
# @api.constrains('suitable_machining_method_ids')
|
||||
# def _check_suitable_machining_method_ids(self):
|
||||
# for record in self:
|
||||
@@ -406,9 +410,31 @@ class ResProductMo(models.Model):
|
||||
|
||||
@api.onchange('cutting_tool_material_id')
|
||||
def _onchange_cutting_tool_material_id(self):
|
||||
for item in self:
|
||||
if item.cutting_tool_material_id.id != item.cutting_tool_model_id.cutting_tool_material_id.id:
|
||||
item.cutting_tool_model_id = False
|
||||
try:
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||
url = config['sf_url'] + '/api/cutting_model/list'
|
||||
res = {'token': config['token'], 'cutting_tool_material_code': self.cutting_tool_material_id.code}
|
||||
result = requests.post(url, json={}, data=res, headers=headers)
|
||||
result = result.json()
|
||||
if result['status'] == 1:
|
||||
self.cutting_tool_model = result['data']
|
||||
except Exception as e:
|
||||
logging.info("获取刀具标准库失败")
|
||||
|
||||
@api.depends('cutting_tool_material_id')
|
||||
def _get_cutting_tool_model(self):
|
||||
try:
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||
url = config['sf_url'] + '/api/cutting_model/list'
|
||||
res = {'token': config['token'], 'cutting_tool_material_code': self.cutting_tool_material_id.code}
|
||||
result = requests.post(url, json=res, data=None, headers=headers)
|
||||
cutting_model_data = result.json()
|
||||
if result['state'] == 1:
|
||||
return {'cutting_model_data': cutting_model_data}
|
||||
except Exception as e:
|
||||
logging.info("获取刀具标准库失败")
|
||||
|
||||
@api.onchange('fixture_material_id')
|
||||
def _onchange_fixture_material_id(self):
|
||||
@@ -736,9 +762,9 @@ class ResProductMo(models.Model):
|
||||
|
||||
# 将attach的datas内容转为glb文件
|
||||
def transition_glb_file(self, report_path, code):
|
||||
shapes = read_step_file(report_path)
|
||||
# shapes = read_step_file(report_path)
|
||||
output_file = os.path.join('/tmp', str(code) + '.stl')
|
||||
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
||||
# write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
||||
# 转化为glb
|
||||
output_glb_file = os.path.join('/tmp', str(code) + '.glb')
|
||||
util_path = get_resource_path('sf_dlm', 'static/util')
|
||||
@@ -783,6 +809,7 @@ class ResMrpBomMo(models.Model):
|
||||
# 坯料BOM组件:选取当前坯料原材料,
|
||||
# 然后根据当前的坯料的体积得出需要的原材料重量(立方米m³) *材料密度 * 1000 = 所需原材料重量KG(公斤)
|
||||
# 坯料所需原材料公式:当前的坯料的体积(立方米m³) *材料密度 * 1000 = 所需原材料重量KG(公斤)
|
||||
|
||||
def bom_create_line(self, embryo):
|
||||
# 选取当前坯料原材料
|
||||
raw_bom_line = self.get_raw_bom(embryo)
|
||||
@@ -801,7 +828,6 @@ class ResMrpBomMo(models.Model):
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
# 查询材料型号默认排第一的供应商
|
||||
|
||||
def get_supplier(self, materials_type):
|
||||
|
||||
Reference in New Issue
Block a user