sf刀具重构完成,同步方法测试完成
This commit is contained in:
267
sf_base/models/tool_base_new.py
Normal file
267
sf_base/models/tool_base_new.py
Normal file
@@ -0,0 +1,267 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import fields, models, api
|
||||
# from datetime import datetime
|
||||
# from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
# 刀具物料
|
||||
class CuttingToolMaterial(models.Model):
|
||||
_name = 'sf.cutting.tool.material'
|
||||
_description = '刀具物料'
|
||||
|
||||
code = fields.Char('编码')
|
||||
name = fields.Char('名称')
|
||||
remark = fields.Char('备注')
|
||||
|
||||
|
||||
# 功能刀具
|
||||
class FunctionalCuttingTool(models.Model):
|
||||
_name = 'sf.functional.cutting.tool'
|
||||
_description = '功能刀具'
|
||||
|
||||
code = fields.Char('编码')
|
||||
name = fields.Char('名称')
|
||||
mrs_cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='功能刀具类型')
|
||||
mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='刀具型号')
|
||||
diameter = fields.Float('直径(mm)')
|
||||
tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')],
|
||||
string='刀具等级')
|
||||
machining_accuracy = fields.Float('加工精度(mm)')
|
||||
tool_length = fields.Float('装刀长')
|
||||
blade_number = fields.Integer('刃数')
|
||||
integral_blade_length = fields.Float('整体刃长(mm)')
|
||||
effective_blade_length = fields.Float('有效刃长(mm)')
|
||||
max_life = fields.Float('最大寿命值')
|
||||
is_standard = fields.Boolean('是否标准刀')
|
||||
applicable_range = fields.Char('适用范围')
|
||||
image = fields.Binary('图片')
|
||||
|
||||
|
||||
# 功能刀具类型
|
||||
class FunctionalCuttingToolModel(models.Model):
|
||||
_name = 'sf.functional.cutting.tool.model'
|
||||
_description = '功能刀具类型'
|
||||
|
||||
name = fields.Char('名称', required=True)
|
||||
code = fields.Char('编码', required=True)
|
||||
remark = fields.Char('备注')
|
||||
|
||||
|
||||
# 刀具型号
|
||||
class CuttingToolModel(models.Model):
|
||||
_name = 'sf.cutting.tool.model'
|
||||
_description = '刀具型号'
|
||||
|
||||
name = fields.Char('名称')
|
||||
code = fields.Char('编码')
|
||||
mrs_machine_brand_id = fields.Many2one('sf.machine.brand', '品牌')
|
||||
mrs_materials_model_id = fields.Many2one('sf.materials.model', '材料型号')
|
||||
# 关联刀具物料
|
||||
mrs_cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料', required=True)
|
||||
# 关联刀具物料名称
|
||||
mrs_cutting_tool_material_name = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料名称',
|
||||
store=True)
|
||||
# 关联刀具类型
|
||||
mrs_cutting_tool_type_id = fields.Many2one(
|
||||
'sf.cutting.tool.type', '刀具类型',
|
||||
domain="[('mrs_cutting_tool_material_id.name', '=', mrs_cutting_tool_material_name)]", required=True)
|
||||
|
||||
# 整体式刀具特有字段
|
||||
integral_code = fields.Char('整体式刀具编码')
|
||||
integral_total_length = fields.Float('总长度(mm)')
|
||||
integral_shank_length = fields.Float('柄部长度(mm)')
|
||||
integral_blade_length = fields.Float('刃部长度(mm)')
|
||||
integral_diameter = fields.Float('直径(mm)')
|
||||
integral_blade_number = fields.Integer('刃数')
|
||||
integral_front_angle = fields.Float('前角(°)')
|
||||
integral_rear_angle = fields.Float('后角(°)')
|
||||
integral_main_included_angle = fields.Float('主偏角(°)')
|
||||
integral_nut = fields.Float('配对螺母(mm)')
|
||||
integral_scope = fields.Char('适用范围')
|
||||
|
||||
# 刀片特有字段
|
||||
blade_code = fields.Char('刀片编码')
|
||||
blade_length = fields.Float('长度L(mm)')
|
||||
blade_width = fields.Float('宽度D(mm)')
|
||||
blade_height = fields.Float('高度T(mm)')
|
||||
blade_top_angle = fields.Float('顶角(°)')
|
||||
blade_front_angle = fields.Float('前角(°)')
|
||||
blade_rear_angle = fields.Float('后角(°)')
|
||||
blade_main_included_angle = fields.Float('主偏角(°)')
|
||||
blade_r_angle = fields.Float('R角(°)')
|
||||
blade_hardness = fields.Char('加工硬度')
|
||||
blade_radius = fields.Float('刀尖半径(mm)')
|
||||
blade_nut = fields.Float('配对螺母(mm)')
|
||||
mrs_cutting_tool_model_blade_cutter_bar_ids = fields.Many2many(
|
||||
'sf.cutting.tool.model',
|
||||
relation='sf_cutting_tool_model_blade_cutter_bar_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('mrs_cutting_tool_material_id.name', '=', '刀杆')]",
|
||||
string='适用刀杆型号',
|
||||
default=lambda self: [], # 使用空列表作为默认值
|
||||
)
|
||||
mrs_cutting_tool_model_blade_cutter_pad_ids = fields.Many2many(
|
||||
'sf.cutting.tool.model',
|
||||
relation='sf_cutting_tool_model_blade_cutter_pad_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('mrs_cutting_tool_material_id.name', '=', '刀盘')]",
|
||||
string='适用刀盘型号',
|
||||
default=lambda self: [], # 使用空列表作为默认值
|
||||
)
|
||||
|
||||
# 刀杆特有字段
|
||||
bar_code = fields.Char('刀杆编码', readonly=True)
|
||||
bar_c_diameter = fields.Float('C柄径(mm)')
|
||||
bar_total_length = fields.Float('L总长(mm)')
|
||||
bar_blade_number = fields.Integer('刃数')
|
||||
bar_d_diameter = fields.Float('D刃径(mm)')
|
||||
mrs_cutting_tool_model_bar_blade_ids = fields.Many2many(
|
||||
'sf.cutting.tool.model',
|
||||
relation='sf_cutting_tool_model_bar_blade_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('mrs_cutting_tool_material_id.name', '=', '刀片')]",
|
||||
string='适用刀片型号',
|
||||
default=lambda self: [], # 使用空列表作为默认值
|
||||
)
|
||||
bar_wrench = fields.Float('配对扳手(mm)')
|
||||
bar_screw = fields.Float('配备螺丝(mm)')
|
||||
bar_radius = fields.Float('刀尖圆角半径')
|
||||
bar_accuracy = fields.Char('精度等级')
|
||||
bar_hardness = fields.Char('硬度(°)')
|
||||
bar_scope = fields.Char('适用范围')
|
||||
|
||||
# 刀盘特有字段
|
||||
pad_code = fields.Char('刀盘编码', readonly=True)
|
||||
pad_c_diameter = fields.Float('C柄径(mm)')
|
||||
pad_total_length = fields.Float('L总长(mm)')
|
||||
pad_blade_number = fields.Integer('刃数')
|
||||
pad_d_diameter = fields.Float('D刃径(mm)')
|
||||
mrs_cutting_tool_model_pad_blade_ids = fields.Many2many(
|
||||
'sf.cutting.tool.model',
|
||||
relation='sf_cutting_tool_model_pad_blade_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('mrs_cutting_tool_material_id.name', '=', '刀片')]",
|
||||
string='适用刀片型号',
|
||||
default=lambda self: [], # 使用空列表作为默认值
|
||||
)
|
||||
pad_wrench = fields.Float('配对扳手(mm)')
|
||||
pad_screw = fields.Float('配备螺丝(mm)')
|
||||
pad_radius = fields.Float('刀尖圆角半径')
|
||||
pad_accuracy = fields.Char('精度等级')
|
||||
pad_hardness = fields.Char('硬度(°)')
|
||||
pad_scope = fields.Char('适用范围')
|
||||
|
||||
# 刀柄特有字段
|
||||
handle_code = fields.Char('刀柄编码', readonly=True)
|
||||
handle_length = fields.Float('L(mm)')
|
||||
handle_length1 = fields.Float('L1(mm)')
|
||||
handle_diameter1 = fields.Float('D1(mm)')
|
||||
handle_weight = fields.Float('重量(kg)')
|
||||
handle_body_accuracy = fields.Float('本体精度(mm)')
|
||||
handle_nut = fields.Float('配对螺母(mm)')
|
||||
mrs_cutting_tool_model_handle_chuck_model_ids = fields.Many2many(
|
||||
'sf.cutting.tool.model',
|
||||
relation='sf_cutting_tool_model_handle_chuck_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('mrs_cutting_tool_material_id.name', '=', '夹头')]",
|
||||
string='适用夹头型号',
|
||||
|
||||
)
|
||||
handle_clamping_range = fields.Float('夹持范围(mm)')
|
||||
handle_detection_accuracy = fields.Float('检测精度')
|
||||
handle_detection_hardness = fields.Char('检测硬度')
|
||||
handle_standard_speed = fields.Float('标准转速')
|
||||
|
||||
# 夹头特有字段
|
||||
chuck_code = fields.Char('夹头编码', readonly=True)
|
||||
chuck_accuracy = fields.Float('精度(mm)')
|
||||
chuck_diameter = fields.Float('外径(mm)')
|
||||
chuck_inner_diameter = fields.Float('内径(mm)')
|
||||
chuck_height = fields.Float('高度(mm)')
|
||||
chuck_nut = fields.Float('配对螺母(mm)')
|
||||
mrs_cutting_tool_model_chuck_handle_model_ids = fields.Many2many(
|
||||
'sf.cutting.tool.model',
|
||||
relation='sf_cutting_tool_model_chuck_handle_rel',
|
||||
column1='model_id_1',
|
||||
column2='model_id_2',
|
||||
domain="[('mrs_cutting_tool_material_id.name', '=', '刀柄')]",
|
||||
string='适用刀柄型号',
|
||||
default=lambda self: [], # 使用空列表作为默认值
|
||||
)
|
||||
chuck_clamping_range = fields.Float('夹持范围(mm)')
|
||||
chuck_feature = fields.Char('特性')
|
||||
|
||||
image = fields.Binary('图片')
|
||||
|
||||
hide_integral = fields.Boolean(compute='_compute_hide_model_number', default=False, string='隐藏整体式刀具')
|
||||
hide_blade = fields.Boolean(compute='_compute_hide_model_number', default=False, string='隐藏刀片')
|
||||
hide_cutter_bar = fields.Boolean(compute='_compute_hide_model_number', default=False, string='隐藏刀杆')
|
||||
hide_cutter_pad = fields.Boolean(compute='_compute_hide_model_number', default=False, string='隐藏刀盘')
|
||||
hide_handler = fields.Boolean(compute='_compute_hide_model_number', default=False, string='隐藏刀柄')
|
||||
hide_chuck = fields.Boolean(compute='_compute_hide_model_number', default=False, string='隐藏夹头')
|
||||
hide_model = fields.Boolean(compute='_compute_hide_model_number', default=True, string='隐藏型号')
|
||||
|
||||
@api.depends('mrs_cutting_tool_material_id')
|
||||
def _compute_hide_model_number(self):
|
||||
"""
|
||||
根据刀具物料类型,显示不同的字段
|
||||
"""
|
||||
for record in self:
|
||||
record.hide_integral = False
|
||||
record.hide_blade = False
|
||||
record.hide_cutter_bar = False
|
||||
record.hide_cutter_pad = False
|
||||
record.hide_handler = False
|
||||
record.hide_chuck = False
|
||||
record.hide_model = True
|
||||
|
||||
if record.mrs_cutting_tool_material_id and record.mrs_cutting_tool_material_id.name == '整体式刀具':
|
||||
record.hide_model = False
|
||||
record.hide_integral = True
|
||||
elif record.mrs_cutting_tool_material_id and record.mrs_cutting_tool_material_id.name == '刀片':
|
||||
record.hide_model = False
|
||||
record.hide_blade = True
|
||||
elif record.mrs_cutting_tool_material_id and record.mrs_cutting_tool_material_id.name == '刀杆':
|
||||
record.hide_model = False
|
||||
record.hide_cutter_bar = True
|
||||
elif record.mrs_cutting_tool_material_id and record.mrs_cutting_tool_material_id.name == '刀盘':
|
||||
record.hide_model = False
|
||||
record.hide_cutter_pad = True
|
||||
elif record.mrs_cutting_tool_material_id and record.mrs_cutting_tool_material_id.name == '刀柄':
|
||||
record.hide_model = False
|
||||
record.hide_handler = True
|
||||
elif record.mrs_cutting_tool_material_id and record.mrs_cutting_tool_material_id.name == '夹头':
|
||||
record.hide_model = False
|
||||
record.hide_chuck = True
|
||||
else:
|
||||
record.hide_model = True
|
||||
|
||||
|
||||
# 刀具类型
|
||||
class CuttingToolType(models.Model):
|
||||
_name = 'sf.cutting.tool.type'
|
||||
_description = '刀具类型'
|
||||
|
||||
code = fields.Char('编码')
|
||||
name = fields.Char('名称')
|
||||
# 关联刀具物料
|
||||
mrs_cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料')
|
||||
# 整体式刀具类型特有字段
|
||||
integral_tool_type_code = fields.Char('整体式刀具类型编码')
|
||||
# 刀片类型特有字段
|
||||
blade_type_code = fields.Char('刀片类型编码')
|
||||
# 刀杆类型特有字段
|
||||
bar_type_code = fields.Char('刀杆类型编码')
|
||||
# 刀盘类型特有字段
|
||||
pad_type_code = fields.Char('刀盘类型编码')
|
||||
# 刀柄类型特有字段
|
||||
handle_type_code = fields.Char('刀柄类型编码')
|
||||
# 夹头类型特有字段
|
||||
chuck_type_code = fields.Char('夹头类型编码')
|
||||
|
||||
remark = fields.Char('备注')
|
||||
Reference in New Issue
Block a user