Files
test/sf_base/models/tool_other_features.py

390 lines
20 KiB
Python

from odoo import fields, models, api
class ToolMaterialsBasicParameters(models.Model):
_name = 'sf.tool.materials.basic.parameters'
_description = '刀具物料基本参数'
name = fields.Char('物料号', size=50)
standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具标准库')
cutting_tool_type = fields.Char(related='standard_library_id.cutting_tool_type', string='刀具物料类型',
store=True)
# 整体式刀具参数
# code = fields.Char('物料号', size=50)
total_length = fields.Char('总长度(mm)', size=20)
blade_number = fields.Selection(
[('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8')],
string='刃数(个)')
neck_diameter = fields.Char('颈部直径(mm)', size=20)
neck_length = fields.Char('颈部长度(mm)', size=20)
handle_diameter = fields.Char('柄部直径(mm)', size=20)
handle_length = fields.Char('柄部长度(mm)', size=20)
blade_tip_diameter = fields.Char('刀尖直径(mm)', size=20)
blade_tip_working_size = fields.Char('刀尖处理尺寸(R半径mm/倒角)', size=20)
blade_tip_taper = fields.Integer('刀尖锥度(°)')
blade_diameter = fields.Char('刃部直径(mm)', size=20)
blade_length = fields.Char('刃部长度(mm)', size=20)
blade_helix_angle = fields.Integer('刃部螺旋角(°)')
blade_width = fields.Char('刃部宽度(mm)', size=20)
blade_depth = fields.Char('刃部深度(mm)', size=20)
pitch = fields.Char('牙距(mm)', size=20)
cutting_depth = fields.Char('切削深度(mm)', size=20)
# 刀片参数
length = fields.Char('长度(mm)', size=20)
thickness = fields.Char('厚度(mm)', size=20)
width = fields.Char('宽度(mm)', size=20)
cutting_blade_length = fields.Char('切削刃长(mm)', size=20)
relief_angle = fields.Integer('后角(°)')
blade_tip_circular_arc_radius = fields.Char('刀尖圆弧半径(mm)', size=20)
inscribed_circle_diameter = fields.Char('内接圆直径(mm)', size=20)
install_aperture_diameter = fields.Char('安装孔直径(mm)', size=20)
chip_breaker_groove = fields.Selection([('', ''), ('单面', '单面'), ('双面', '双面')],
string='有无断屑槽')
blade_teeth_model = fields.Selection(
[('V牙型', 'V牙型'), ('米制全牙型', '米制全牙型'), ('美制全牙型', '美制全牙型'),
('惠氏全牙型', '惠氏全牙型'), ('BSPT全牙型', 'BSPT全牙型'), ('NPT全牙型', 'NPT全牙型'),
('UNJ全牙型', 'UNJ全牙型'), ('DIN405圆牙型', 'DIN405圆牙型'), ('ACME梯形', 'ACME梯形'),
('石油管螺纹刀片', '石油管螺纹刀片'), ('矮牙ACME梯形', '矮牙ACME梯形'),
('Trapeze30° 103', 'Trapeze30° 103')], string='刀片牙型')
blade_blade_number = fields.Selection([('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'),
('7', '7'), ('8', '8'), ('9', '9'), ('10', '10')],
string='刀片的刃数(个)')
main_included_angle = fields.Integer('主偏角(°)')
top_angle = fields.Integer('顶角(°)')
blade_tip_dip_angle = fields.Integer('刀尖倾角(°)')
side_cutting_edge_angle = fields.Integer('侧切削角(°)')
thread_model = fields.Selection([('外螺纹', '外螺纹'), ('内螺纹', '内螺纹')], string='螺纹类型')
thread_num = fields.Char('每英寸螺纹数(TPI)', size=20)
blade_tip_height_tolerance = fields.Char('刀尖高度公差(mm)', size=20)
inscribed_circle_tolerance = fields.Char('内接圆公差(mm)', size=20)
thickness_tolerance = fields.Char('厚度公差(mm)', size=20)
# 刀杆参数
height = fields.Char('高度(mm)', size=20)
blade_height = fields.Char('刃部高度(mm)', size=20)
cutter_arbor_diameter = fields.Char('刀杆直径(mm)', size=20)
min_machining_aperture = fields.Char('最小加工孔径(mm)', size=20)
install_blade_tip_num = fields.Char('可装刀片数/齿数(个)', size=20)
cutting_blade_model = fields.Char('切削类型', size=20)
cooling_hole = fields.Selection([('', ''), ('', '')], string='有无冷却孔')
locating_slot_code = fields.Char('定位槽代号', size=20)
installing_structure = fields.Char('安装结构', size=20)
blade_ids = fields.Many2many(
'sf.cutting.tool.type',
relation='basic_param_pad_blade_rel',
column1='model_id_1',
column2='model_id_2',
domain="[('cutting_tool_material_id.name', '=', '刀片')]",
string='适配刀片型号' # 使用空列表作为默认值
)
tool_shim = fields.Char('适配刀垫型号', size=50)
cotter_pin = fields.Char('适配销钉型号', size=50)
pressing_plate = fields.Char('适配压板型号', size=50)
screw = fields.Char('适配螺钉型号', size=50)
spanner = fields.Char('适配扳手型号', size=50)
# 刀盘参数
cutter_head_diameter = fields.Char('刀盘直径(mm)', size=20)
interface_diameter = fields.Char('接口直径(mm)', size=20)
# 刀柄参数
flange_shank_length = fields.Char('法兰柄长(mm)', size=20)
handle_external_diameter = fields.Char('柄部外径(mm)', size=20)
handle_inside_diameter = fields.Char('柄部内径(mm)', size=20)
min_clamping_diameter = fields.Char('最小夹持直径(mm)', size=20)
max_clamping_diameter = fields.Char('最大夹持直径(mm)', size=20)
clamping_mode = fields.Char('夹持方式', size=20)
max_load_capacity = fields.Char('最大负载能力(kg)', size=20)
taper = fields.Integer('锥度(°)')
tool_changing_time = fields.Integer('换刀时间(s)')
standard_rotate_speed = fields.Char('标准转速(n/min)', size=20)
max_rotate_speed = fields.Char('最大转速(n/min)', size=20)
diameter_slip_accuracy = fields.Char('径跳精度(mm)', size=20)
cooling_model = fields.Char('冷却类型', size=20)
is_rough_machining = fields.Selection([('', ''), ('', '')], string='是否可粗加工')
is_finish_machining = fields.Selection([('', ''), ('', '')], string='是否可精加工')
is_quick_cutting = fields.Selection([('', ''), ('', '')], string='是否可高速切削')
is_drill_hole = fields.Selection([('', ''), ('', '')], string='是否可钻孔')
is_safe_lock = fields.Selection([('', ''), ('', '')], string='有无安全锁')
# 夹头参数
er_size_model = fields.Char('ER尺寸型号', size=20)
outer_diameter = fields.Char('外径(mm)', size=20)
inner_diameter = fields.Char('内径(mm)', size=20)
run_out_accuracy = fields.Char('跳动精度(mm)', size=20)
top_diameter = fields.Char('顶部直径(mm)', size=20)
weight = fields.Char('重量(kg)', size=20)
clamping_length = fields.Char('夹持长度(mm)', size=20)
clamping_tolerance = fields.Char('夹持公差(mm)', size=20)
cooling_jacket = fields.Char('适用冷却套型号', size=50)
handle_ids = fields.Many2many(
'sf.cutting.tool.type',
relation='basic_param_chuck_handle_rel',
column1='model_id_1',
column2='model_id_2',
domain="[('cutting_tool_material_id.name', '=', '刀柄')]",
string='适用刀柄型号'
)
def name_get(self):
res = []
for obj in self:
res.append((obj.id, obj.blade_diameter))
return res
def _json_integral_tool_basic_param(self, obj):
integral_tool_basic_param_str = (0, '', {
'name': obj['code'],
'cutting_tool_type': obj['cutting_tool_type'],
'total_length': obj['total_length'],
'blade_diameter': obj['blade_diameter'],
'blade_length': obj['blade_length'],
'blade_number': obj['blade_number'],
'neck_length': obj['neck_length'],
'neck_diameter': obj['neck_diameter'],
'handle_diameter': obj['handle_diameter'],
'handle_length': obj['handle_length'],
'blade_tip_diameter': obj['blade_tip_diameter'],
'blade_tip_working_size': obj['blade_tip_working_size'],
'blade_tip_taper': obj['blade_tip_taper'],
'blade_helix_angle': obj['blade_helix_angle'],
'blade_width': obj['blade_width'],
'blade_depth': obj['blade_depth'],
'pitch': obj['pitch'],
'cutting_depth': obj['cutting_depth'],
})
return integral_tool_basic_param_str
def _json_blade_basic_param(self, obj):
blade_basic_param_str = (0, '', {
'name': obj['code'],
'cutting_tool_type': obj['cutting_tool_type'],
'length': obj['length'],
'thickness': obj['thickness'],
'width': obj['width'],
'cutting_blade_length': obj['cutting_blade_length'],
'relief_angle': obj['relief_angle'],
'blade_tip_circular_arc_radius': obj['blade_tip_circular_arc_radius'],
'inscribed_circle_diameter': obj['inscribed_circle_diameter'],
'install_aperture_diameter': obj['install_aperture_diameter'],
'pitch': obj['pitch'],
'chip_breaker_groove': obj['chip_breaker_groove'],
'blade_teeth_model': obj['bladed_teeth_model'],
'blade_blade_number': obj['blade_blade_number'],
'cutting_depth': obj['cutting_depth'],
'blade_width': obj['blade_width'],
'main_included_angle': obj['main_included_angle'],
'top_angle': obj['top_angle'],
'blade_tip_dip_angle': obj['blade_tip_dip_angle'],
'side_cutting_edge_angle': obj['side_cutting_edge_angle'],
'thread_model': obj['thread_model'],
'thread_num': obj['thread_num'],
'blade_tip_height_tolerance': obj['blade_tip_height_tolerance'],
'inscribed_circle_tolerance': obj['inscribed_circle_tolerance'],
'thickness_tolerance': obj['thickness_tolerance'],
})
return blade_basic_param_str
def _json_cutter_arbor_basic_param(self, obj):
cutter_arbor_basic_param_str = (0, '', {
'name': obj['code'],
'cutting_tool_type': obj['cutting_tool_type'],
'height': obj['height'],
'width': obj['width'],
'blade_height': obj['blade_height'],
'total_length': obj['total_length'],
'blade_width': obj['blade_width'],
'blade_length': obj['blade_length'],
'blade_height': obj['blade_height'],
'cutter_arbor_diameter': obj['cutter_arbor_diameter'],
'main_included_angle': obj['main_included_angle'],
'relief_angle': obj['relief_angle'],
'cutting_depth': obj['cutting_depth'],
'min_machining_aperture': obj['min_machining_aperture'],
'install_blade_tip_num': obj['install_blade_tip_num'],
'cutting_blade_model': obj['cutting_blade_model'],
'cooling_hole': obj['cooling_hole'],
'locating_slot_code': obj['locating_slot_code'],
'installing_structure': obj['installing_structure'],
'blade_ids': [(6, 0, [])] if not obj.get('blade_codes') else self.evn['sf.cutting.tool.type']._get_ids(
obj['blade_codes']),
'tool_shim': obj['tool_shim'],
'cotter_pin': obj['cotter_pin'],
'pressing_plate': obj['pressing_plate'],
'screw': obj['screw'],
'spanner': obj['spanner'],
})
return cutter_arbor_basic_param_str
def _json_cutter_head_basic_param(self, obj):
cutter_head_basic_param_str = (0, '', {
'name': obj['code'],
'cutting_tool_type': obj['cutting_tool_type'],
'install_blade_tip_num': obj['install_blade_tip_num'],
'blade_diameter': obj['blade_diameter'],
'cutter_head_diameter': obj['cutter_head_diameter'],
'interface_diameter': obj['interface_diameter'],
'total_length': obj['total_length'],
'blade_length': obj['blade_length'],
'cutting_depth': obj['cutting_depth'],
'main_included_angle': obj['main_included_angle'],
'installing_structure': obj['installing_structure'],
'blade_ids': [(6, 0, [])] if not obj.get('blade_codes') else self.evn['sf.cutting.tool.type']._get_ids(
obj['blade_codes']),
'screw': obj['screw'],
'spanner': obj['spanner'],
'cutting_blade_model': obj['cutting_blade_model'],
'cooling_hole': obj['cooling_hole'],
'locating_slot_code': obj['locating_slot_code'],
})
return cutter_head_basic_param_str
def _json_knife_handle_basic_param(self, obj):
knife_handle_basic_param_str = (0, '', {
'name': obj['code'],
'cutting_tool_type': obj['cutting_tool_type'],
'total_length': obj['total_length'],
'flange_shank_length': obj['flange_shank_length'],
'handle_external_diameter': obj['handle_external_diameter'],
'handle_inside_diameter': obj['handle_inside_diameter'],
'min_clamping_diameter': obj['min_clamping_diameter'],
'max_clamping_diameter': obj['max_clamping_diameter'],
'clamping_mode': obj['clamping_mode'],
'max_load_capacity': obj['max_load_capacity'],
'taper': obj['taper'],
'tool_changing_time': obj['tool_changing_time'],
'standard_rotate_speed': obj['standard_rotate_speed'],
'max_rotate_speed': obj['max_rotate_speed'],
'diameter_slip_accuracy': obj['diameter_slip_accuracy'],
'cooling_model': obj['cooling_model'],
'is_rough_machining': obj['whether_rough_machining'],
'is_finish_machining': obj['whether_finish_machining'],
'is_quick_cutting': obj['whether_quick_cutting'],
'is_drill_hole': obj['whether_drill_hole'],
'is_safe_lock': obj['whether_safe_lock'],
'screw': obj['screw'],
'spanner': obj['spanner'],
})
return knife_handle_basic_param_str
def _json_chuck_basic_param(self, obj):
chuck_basic_param_str = (0, '', {
'name': obj['code'],
'cutting_tool_type': obj['cutting_tool_type'],
'er_size_model': obj['er_size_model'],
'min_clamping_diameter': obj['min_clamping_diameter'],
'max_clamping_diameter': obj['max_clamping_diameter'],
'outer_diameter': obj['outer_diameter'],
'inner_diameter': obj['inner_diameter'],
'run_out_accuracy': obj['run_out_accuracy'],
'total_length': obj['total_length'],
'taper': obj['taper'],
'run_out_accuracy': obj['run_out_accuracy'],
'top_diameter': obj['top_diameter'],
'weight': obj['weight'],
'clamping_mode': obj['clamping_mode'],
'clamping_length': obj['clamping_length'],
'clamping_tolerance': obj['clamping_tolerance'],
'max_load_capacity': obj['max_load_capacity'],
'handle_ids': [(6, 0, [])] if not obj.get(
'handle_codes') else self.evn['sf.cutting.tool.type']._get_ids(obj['handle_codes']),
'cooling_jacket': obj['cooling_jacket'],
})
return chuck_basic_param_str
class CuttingSpeed(models.Model):
_name = 'sf.cutting.speed'
_description = '切削速度Vc'
product_template_id = fields.Many2one('product.template')
specification_id = fields.Many2one('sf.cutting_tool.specification.wizard', string='刀具规格')
standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='标准库')
execution_standard_id = fields.Many2one('sf.international.standards', string='执行标准', store=True)
material_code = fields.Char('材料代号')
material_id = fields.Many2one('sf.materials.model', '材料名称',
domain="[('standards_id', '=', execution_standard_id)]")
slope_milling_angle = fields.Integer('坡铣角度(°)')
material_grade = fields.Char('材料牌号')
tensile_strength = fields.Char('拉伸强度 (N/mm²)')
hardness = fields.Float('硬度(HRC)')
cutting_speed_n1 = fields.Char('径向切宽 ae=100%D1 ap=1*D1 切削速度Vc')
cutting_speed_n2 = fields.Char('径向切宽 ae=50%D1 ap=1.5*D1 切削速度Vc')
cutting_speed_n3 = fields.Char('径向切宽 ae=25%D1 ap=L1max 切削速度Vc')
cutting_speed_n4 = fields.Char('径向切宽 ae=15%D1 ap=L1max 切削速度Vc')
cutting_speed_n5 = fields.Char('径向切宽 ae=5%D1 ap=L1max 切削速度Vc')
rough_machining = fields.Char('粗加工 Vc(m/min)')
precision_machining = fields.Char('精加工 Vc(m/min)')
application = fields.Selection([('主应用', '主应用'), ('次应用', '次应用')], '主/次应用')
def _json_cutting_speed(self, obj):
cutting_speed_str = (0, '', {
'execution_standard_id': self.env['sf.international.standards'].search(
[('code', '=', obj['execution_standard_code'])]).id,
'material_code': obj['material_code'],
'material_id': self.env['sf.materials.model'].search([('materials_no', '=', obj['material_name_code'])]).id,
'material_grade': obj['material_grade'],
'tensile_strength': obj['tensile_strength'],
'hardness': obj['hardness'],
'cutting_speed_n1': obj['cutting_speed_n1'],
'cutting_speed_n2': obj['cutting_speed_n2'],
'cutting_speed_n3': obj['cutting_speed_n3'],
'cutting_speed_n4': obj['cutting_speed_n4'],
'cutting_speed_n5': obj['cutting_speed_n5'],
'rough_machining': obj['rough_machining'],
'precision_machining': obj['precision_machining'],
'application': obj['application'],
})
return cutting_speed_str
class FeedPerTooth(models.Model):
_name = 'sf.feed.per.tooth'
_description = '每齿走刀量fz'
_order = 'machining_method desc, blade_diameter, materials_type_id'
product_template_id = fields.Many2one('product.template')
standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='标准库')
specification_id = fields.Many2one('sf.cutting_tool.specification.wizard', string='刀具规格')
cutting_speed = fields.Char('径向切宽 ae(mm)')
machining_method = fields.Selection([('直铣', '直铣'), ('坡铣', '坡铣')], string='加工方式')
materials_type_id = fields.Many2one('sf.materials.model', string='材料型号')
blade_diameter = fields.Char('刃部直径(mm)', readonly=True)
feed_per_tooth = fields.Char('每齿走刀量 (mm/z)')
def _json_feed_per_tooth(self, obj):
feed_per_tooth_str = (0, '', {
'cutting_speed': obj['cutting_speed'],
'blade_diameter': obj['blade_diameter'],
'feed_per_tooth': obj['feed_per_tooth'],
})
return feed_per_tooth_str
def _json_feed_per_tooth_2(self, obj):
feed_per_tooth_2_str = (0, '', {
'machining_method': obj['machining_method'],
'materials_type_id': self.env['sf.materials.model'].search(
[('materials_no', '=', obj['materials_type_code'])]).id,
'blade_diameter': obj['blade_diameter'],
'feed_per_tooth': obj['feed_per_tooth'],
})
return feed_per_tooth_2_str
def _json_feed_per_tooth_3(self, obj):
feed_per_tooth_3_str = (0, '', {
'cutting_speed': obj['cutting_speed'],
'feed_per_tooth': obj['feed_per_tooth'],
})
return feed_per_tooth_3_str
def _json_feed_per_tooth_4(self, obj):
feed_per_tooth_4_str = (0, '', {
'machining_method': obj['machining_method'],
'materials_type_id': self.env['sf.materials.model'].search(
[('materials_no', '=', obj['materials_type_code'])]).id,
'feed_per_tooth': obj['feed_per_tooth'],
})
return feed_per_tooth_4_str
# @api.depends('product_template_id')
# def _compute_product_template_id(self):
# if self.product_template_id is not None:
# self.blade_diameter = self.product_template_id.cutting_tool_blade_diameter