刀具物料功能模型从sf_base模块迁移到sf_manufacturing模块;新增每齿走刀量模型;整体式刀具物料新增关联每齿走刀量对象字段;

This commit is contained in:
yuxianghui
2023-09-08 10:20:52 +08:00
parent ae3f7c9c0c
commit 35afdd3b2a
13 changed files with 138 additions and 55 deletions

View File

@@ -1,8 +1,8 @@
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
import logging
import base64
import hashlib
@@ -100,7 +100,8 @@ class ResProductMo(models.Model):
cutting_direction_ids = fields.Many2many('sf.cutting.direction', 'rel_cutting_direction_product_template', '走刀方向')
suitable_coolant_ids = fields.Many2many('sf.suitable.coolant', 'rel_suitable_coolant_product_template', '适合冷却液')
cutting_speed_ids = fields.Many2many('sf.cutting.speed', 'rel_sf_cutting_speed', '切削速度Vc')
cutting_speed_ids = fields.One2many('sf.cutting.speed', 'product_template_id', string='切削速度Vc')
feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'product_template_id', string='每齿走刀量fz')
@api.constrains('suitable_machining_method_ids')
def _check_suitable_machining_method_ids(self):
@@ -662,20 +663,20 @@ class ResProductMo(models.Model):
item.model_file = self.transition_glb_file(report_path, model_code)
# 将attach的datas内容转为glb文件
def transition_glb_file(self, report_path, code):
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)
# 转化为glb
output_glb_file = os.path.join('/tmp', str(code) + '.glb')
util_path = get_resource_path('sf_dlm', 'static/util')
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
os.system(cmd)
# 转base64
with open(output_glb_file, 'rb') as fileObj:
image_data = fileObj.read()
base64_data = base64.b64encode(image_data)
return base64_data
# def transition_glb_file(self, report_path, code):
# 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)
# # 转化为glb
# output_glb_file = os.path.join('/tmp', str(code) + '.glb')
# util_path = get_resource_path('sf_dlm', 'static/util')
# cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
# os.system(cmd)
# # 转base64
# with open(output_glb_file, 'rb') as fileObj:
# image_data = fileObj.read()
# base64_data = base64.b64encode(image_data)
# return base64_data
class ResMrpBomMo(models.Model):