Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/自建模块日志警告信息处理
# Conflicts: # sf_base/models/fixture.py # sf_manufacturing/models/model_type.py # sf_manufacturing/models/product_template.py # sf_sale/models/quick_easy_order.py
This commit is contained in:
@@ -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
|
||||
@@ -12,17 +12,21 @@ import os
|
||||
class ResProductMo(models.Model):
|
||||
_inherit = 'product.template'
|
||||
model_file = fields.Binary('模型文件')
|
||||
categ_type = fields.Selection(
|
||||
[("成品", "成品"), ("坯料", "坯料"), ("原材料", "原材料"), ("表面工艺", "表面工艺"), ("刀具", "刀具"),
|
||||
("夹具", "夹具")],
|
||||
string='产品的类别', compute='_compute_categ_id',
|
||||
store=True)
|
||||
|
||||
@api.depends('categ_id')
|
||||
def _compute_categ_id(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.categ_type = record.categ_id.type
|
||||
# categ_type = fields.Selection(
|
||||
# [("成品", "成品"), ("坯料", "坯料"), ("原材料", "原材料"), ("表面工艺", "表面工艺"), ("刀具", "刀具"),
|
||||
# ("夹具", "夹具")],
|
||||
# string='产品的类别', compute='_compute_categ_id',
|
||||
# store=True)
|
||||
#
|
||||
# @api.depends('categ_id')
|
||||
# def _compute_categ_id(self):
|
||||
# for record in self:
|
||||
# if record:
|
||||
# record.categ_type = record.categ_id.type
|
||||
|
||||
|
||||
categ_type = fields.Selection(string='产品的类别', related='categ_id.type', store=True)
|
||||
|
||||
model_name = fields.Char('模型名称')
|
||||
model_long = fields.Float('模型长(mm)', digits=(16, 3))
|
||||
@@ -67,7 +71,8 @@ class ResProductMo(models.Model):
|
||||
tool_width = fields.Integer('宽度(mm)')
|
||||
tool_height = fields.Integer('高度(mm)')
|
||||
tool_thickness = fields.Integer('厚度(mm)')
|
||||
tool_weight = fields.Float('重量(kg)', digits=(16, 3))
|
||||
tool_weight = fields.Float('重量(kg)')
|
||||
|
||||
coating_material = fields.Char('涂层材质')
|
||||
# 整体式刀具参数
|
||||
cutting_tool_total_length = fields.Float('总长度(mm)')
|
||||
@@ -145,10 +150,12 @@ class ResProductMo(models.Model):
|
||||
fixture_clamping_way = fields.Char(string="装夹方式")
|
||||
fixture_port_type = fields.Char(string="接口类型")
|
||||
fixture_model_file = fields.Binary(string="3D模型图")
|
||||
fixture_clamp_workpiece_length_max = fields.Integer(string="夹持工件长度MAX(mm)")
|
||||
fixture_clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度MAX(mm)")
|
||||
fixture_clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX(mm)")
|
||||
fixture_clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径MAX(mm)", digits=(16, 6))
|
||||
|
||||
fixture_clamp_workpiece_length_max = fields.Integer(string="夹持工件长度max(mm)")
|
||||
fixture_clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度max(mm)")
|
||||
fixture_clamp_workpiece_height_max = fields.Integer(string="夹持工件高度max(mm)")
|
||||
fixture_clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径max(mm)", digits=(16, 6))
|
||||
|
||||
fixture_maximum_carrying_weight = fields.Float(string="最大承载重量(kg)", digits=(16, 4))
|
||||
fixture_maximum_clamping_force = fields.Integer(string="最大夹持力(n)")
|
||||
fixture_driving_way = fields.Char(string="驱动方式")
|
||||
@@ -426,7 +433,8 @@ class ResProductMo(models.Model):
|
||||
'materials_type_id': self.env['sf.materials.model'].search(
|
||||
[('materials_no', '=', item['texture_type_code'])]).id,
|
||||
# 'model_surface_process_ids': self.get_production_process_id(item['surface_process_code']),
|
||||
'model_process_parameters_ids': [(6, 0, [])] if not item.get('process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']),
|
||||
'model_process_parameters_ids': [(6, 0, [])] if not item.get(
|
||||
'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']),
|
||||
'model_remark': item['remark'],
|
||||
'default_code': '%s-%s' % (order_number, i),
|
||||
# 'barcode': item['barcode'],
|
||||
@@ -558,20 +566,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):
|
||||
|
||||
Reference in New Issue
Block a user