自建模块日志警告信息处理

This commit is contained in:
yuxianghui
2023-08-28 17:31:41 +08:00
parent df650edefd
commit 39feda07e5
18 changed files with 224 additions and 106 deletions

View File

@@ -1,4 +1,4 @@
from odoo import fields, models
from odoo import fields, models,api
class ResProductCategory(models.Model):
@@ -39,7 +39,15 @@ class ProductModelTypeRoutingSort(models.Model):
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
], string="工序类型", related='route_workcenter_id.routing_type')
], string="工序类型", compute='_compute_route_workcenter_id')
@api.depends('route_workcenter_id')
def _compute_route_workcenter_id(self):
for record in self:
if record:
record.routing_type = record.route_workcenter_id.routing_type
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
product_model_type_id = fields.Many2one('sf.model.type')
@@ -62,7 +70,14 @@ class EmbryoModelTypeRoutingSort(models.Model):
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
], string="工序类型", related='route_workcenter_id.routing_type')
], string="工序类型", compute='_compute_route_workcenter_id')
@api.depends('route_workcenter_id')
def _compute_route_workcenter_id(self):
for record in self:
if record:
record.routing_type = record.route_workcenter_id.routing_type
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
embryo_model_type_id = fields.Many2one('sf.model.type')
@@ -85,7 +100,14 @@ class SurfaceTechnicsModelTypeRoutingSort(models.Model):
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
], string="工序类型", related='route_workcenter_id.routing_type')
], string="工序类型", compute='_compute_route_workcenter_id')
@api.depends('route_workcenter_id')
def _compute_route_workcenter_id(self):
for record in self:
if record:
record.routing_type = record.route_workcenter_id.routing_type
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
surface_technics_model_type_id = fields.Many2one('sf.model.type')

View File

@@ -8,7 +8,7 @@ class ResWorkcenter(models.Model):
_inherit = "mrp.workcenter"
# 生产线显示
production_line_show = fields.Char(string='生产线')
production_line_show = fields.Char(string='生产线名称')
machine_tool_id = fields.Many2one('sf.machine_tool', string='机床')
production_line_id = fields.Many2one('sf.production.line', string='生产线')
is_process_outsourcing = fields.Boolean('工艺外协')
@@ -20,7 +20,13 @@ class ResWorkcenter(models.Model):
equipment_status = fields.Selection(
[("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
string="设备状态", related='equipment_id.state')
string="设备状态", compute='_compute_equipment_id')
@api.depends('equipment_id')
def _compute_equipment_id(self):
for record in self:
if record:
record.equipment_status = record.equipment_id.state
equipment_image = fields.Binary('设备图片', related='equipment_id.machine_tool_picture')

View File

@@ -19,11 +19,11 @@ class ResMrpWorkOrder(models.Model):
_order = 'sequence asc,create_date desc'
product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True,
check_company=True, string="坯料长度(mm)")
string="坯料长度(mm)")
product_tmpl_id_width = fields.Float(related='production_id.product_tmpl_id.width', readonly=True, store=True,
check_company=True, string="坯料宽度(mm)")
string="坯料宽度(mm)")
product_tmpl_id_height = fields.Float(related='production_id.product_tmpl_id.height', readonly=True, store=True,
check_company=True, string="坯料高度(mm)")
string="坯料高度(mm)")
product_tmpl_id_materials_id = fields.Many2one(related='production_id.product_tmpl_id.materials_id', readonly=True,
store=True, check_company=True, string="材料")
product_tmpl_id_materials_type_id = fields.Many2one(related='production_id.product_tmpl_id.materials_type_id',
@@ -41,7 +41,7 @@ class ResMrpWorkOrder(models.Model):
('解除装夹', '解除装夹'),
('切割', '切割'), ('表面工艺', '表面工艺')
], string="工序类型")
results = fields.Char('检测结果')
results = fields.Char('结果')
@api.onchange('users_ids')
def get_user_permissions(self):
@@ -118,7 +118,7 @@ class ResMrpWorkOrder(models.Model):
chuck_brand_id = fields.Many2one('sf.machine.brand', string="卡盘品牌")
chuck_type_id = fields.Char(string="卡盘类型")
chuck_model_id = fields.Char(string="卡盘型号")
tray_serial_number = fields.Char(string="盘序列号")
tray_serial_number = fields.Char(string="盘序列号")
tray_name = fields.Char(string="托盘名称")
tray_brand_id = fields.Many2one('sf.machine.brand', string="托盘品牌")
tray_type_id = fields.Char(string="托盘类型")

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
@@ -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):