自建模块日志警告信息处理
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
|
||||
@@ -15,8 +15,15 @@ class ResProductMo(models.Model):
|
||||
categ_type = fields.Selection(
|
||||
[("成品", "成品"), ("坯料", "坯料"), ("原材料", "原材料"), ("表面工艺", "表面工艺"), ("刀具", "刀具"),
|
||||
("夹具", "夹具")],
|
||||
string='产品的类别', related='categ_id.type',
|
||||
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
|
||||
|
||||
model_name = fields.Char('模型名称')
|
||||
model_long = fields.Float('模型长(mm)', digits=(16, 3))
|
||||
model_width = fields.Float('模型宽(mm)', digits=(16, 3))
|
||||
@@ -56,11 +63,11 @@ class ResProductMo(models.Model):
|
||||
domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]")
|
||||
|
||||
brand_id = fields.Many2one('sf.machine.brand', '品牌')
|
||||
tool_length = fields.Integer('长度(mm)', size=6)
|
||||
tool_width = fields.Integer('宽度(mm)', size=6)
|
||||
tool_height = fields.Integer('高度(mm)', size=6)
|
||||
tool_thickness = fields.Integer('厚度(mm)', size=6)
|
||||
tool_weight = fields.Float('重量(kg)', size=4)
|
||||
tool_length = fields.Integer('长度(mm)')
|
||||
tool_width = fields.Integer('宽度(mm)')
|
||||
tool_height = fields.Integer('高度(mm)')
|
||||
tool_thickness = fields.Integer('厚度(mm)')
|
||||
tool_weight = fields.Float('重量(kg)', digits=(16, 3))
|
||||
coating_material = fields.Char('涂层材质')
|
||||
# 整体式刀具参数
|
||||
cutting_tool_total_length = fields.Float('总长度(mm)')
|
||||
@@ -138,22 +145,73 @@ 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)", size=6)
|
||||
fixture_clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度MAX(mm)", size=6)
|
||||
fixture_clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX(mm)", size=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)", size=8)
|
||||
fixture_maximum_clamping_force = fields.Integer(string="最大夹持力(n)")
|
||||
fixture_driving_way = fields.Char(string="驱动方式")
|
||||
fixture_apply_machine_tool_type_ids = fields.Many2many('sf.machine_tool.type', 'rel_product_machine_tool_type',
|
||||
string="适用机床型号")
|
||||
fixture_through_hole_size = fields.Integer(string="过孔大小(mm)", size=6)
|
||||
fixture_screw_size = fields.Integer(string="螺牙大小(mm)", size=6)
|
||||
fixture_through_hole_size = fields.Integer(string="过孔大小(mm)")
|
||||
fixture_screw_size = fields.Integer(string="螺牙大小(mm)")
|
||||
|
||||
# 注册状态
|
||||
register_state = fields.Selection([('未注册', '未注册'), ('已注册', '已注册'), ('注册失败', '注册失败')],
|
||||
string='注册状态', default='未注册')
|
||||
industry_code = fields.Char('行业编码', readonly=True)
|
||||
|
||||
@api.constrains('tool_length')
|
||||
def _check_tool_length_size(self):
|
||||
if self.tool_length > 1000000:
|
||||
raise ValidationError("长度不能超过1000000")
|
||||
|
||||
@api.constrains('tool_width')
|
||||
def _check_tool_width_size(self):
|
||||
if self.tool_width > 1000000:
|
||||
raise ValidationError("宽度不能超过1000000")
|
||||
|
||||
@api.constrains('tool_height')
|
||||
def _check_tool_height_size(self):
|
||||
if self.tool_height > 1000000:
|
||||
raise ValidationError("高度不能超过1000000")
|
||||
|
||||
@api.constrains('tool_thickness')
|
||||
def _check_tool_thickness_size(self):
|
||||
if self.tool_thickness > 1000000:
|
||||
raise ValidationError("厚度不能超过1000000")
|
||||
|
||||
@api.constrains('fixture_clamp_workpiece_length_max')
|
||||
def _check_fixture_clamp_workpiece_length_max_size(self):
|
||||
if self.fixture_clamp_workpiece_length_max > 1000000:
|
||||
raise ValidationError("夹持工件长度MAX不能超过1000000")
|
||||
|
||||
@api.constrains('fixture_clamp_workpiece_width_max')
|
||||
def _check_fixture_clamp_workpiece_width_max_size(self):
|
||||
if self.fixture_clamp_workpiece_width_max > 1000000:
|
||||
raise ValidationError("夹持工件宽度MAX不能超过1000000")
|
||||
|
||||
@api.constrains('fixture_clamp_workpiece_height_max')
|
||||
def _check_fixture_clamp_workpiece_height_max_size(self):
|
||||
if self.fixture_clamp_workpiece_height_max > 1000000:
|
||||
raise ValidationError("夹持工件高度MAX不能超过1000000")
|
||||
|
||||
@api.constrains('fixture_maximum_clamping_force')
|
||||
def _check_fixture_maximum_clamping_force_size(self):
|
||||
if self.fixture_maximum_clamping_force > 100000000:
|
||||
raise ValidationError("最大夹持力不能超过100000000")
|
||||
|
||||
@api.constrains('fixture_through_hole_size')
|
||||
def _check_fixture_through_hole_size_size(self):
|
||||
if self.fixture_through_hole_size > 1000000:
|
||||
raise ValidationError("过孔大小不能超过1000000")
|
||||
|
||||
@api.constrains('fixture_screw_size')
|
||||
def _check_fixture_through_hole_size_size(self):
|
||||
if self.fixture_screw_size > 1000000:
|
||||
raise ValidationError("螺牙大小不能超过1000000")
|
||||
|
||||
def _json_apply_machine_tool_type_item_code(self, item):
|
||||
code_arr = []
|
||||
for i in item.product_id.fixture_apply_machine_tool_type_ids:
|
||||
@@ -500,20 +558,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