diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py index 84044f1c..dac651e1 100644 --- a/sf_tool_management/models/tool_material_search.py +++ b/sf_tool_management/models/tool_material_search.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from odoo import fields, models, api, SUPERUSER_ID +from odoo.exceptions import ValidationError # 刀具物料搜索 @@ -9,22 +10,22 @@ class SfToolMaterialSearch(models.Model): sequence = fields.Integer('序号') code = fields.Char('编码') - name = fields.Char('名称') + name = fields.Char('名称', required=True) # 关联刀具类型 mrs_cutting_tool_type_id = fields.Many2one( 'sf.cutting.tool.type', '刀具类型', - domain="[('cutting_tool_material_id.name', '=', cutting_tool_material_name)]") + domain="[('cutting_tool_material_id.name', '=', cutting_tool_material_name)]", required=True) # 关联刀具物料名称 mrs_cutting_tool_material_name = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料名称', store=True) cutting_tool_type = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料类型', store=True) - mrs_machine_brand_id = fields.Many2one('sf.machine.brand', '品牌') + mrs_machine_brand_id = fields.Many2one('sf.machine.brand', '品牌', required=True) # 关联刀具型号 # mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', '刀具型号') # 关联刀具物料模型 mrs_cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料', - group_expand='_read_group_mrs_cutting_tool_material_ids') + group_expand='_read_group_mrs_cutting_tool_material_ids', required=True) cutting_tool_material_name = fields.Char(string='物料名称', invisible=True) @api.onchange('mrs_cutting_tool_material_id') @@ -74,19 +75,73 @@ class SfToolMaterialSearch(models.Model): # 整体式刀具特有字段 integral_code = fields.Char('整体式刀具编码', readonly=True) - 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_accuracy = fields.Float('整体式刀具精度等级') - integral_hardness = fields.Float('整体式刀具加工硬度(HRC)') + integral_total_length = fields.Float('整体式刀具总长度(mm)', digits=(6, 1)) + integral_shank_length = fields.Float('整体式刀具柄部长度(mm)', digits=(6, 1)) + integral_blade_length = fields.Float('整体式刀具刃部长度(mm)', digits=(6, 1)) + integral_neck_length = fields.Float('整体式刀具颈部长度(mm)', digits=(6, 1)) + integral_shank_diameter = fields.Float('整体式刀具柄部直径(mm)', digits=(6, 1)) + integral_blade_diameter = fields.Float('整体式刀具刃部直径(mm)', digits=(6, 1)) + integral_neck_diameter = fields.Float('整体式刀具颈部直径(mm)', digits=(6, 1)) + integral_blade_number = fields.Integer('整体式刀具刃数(个)') + integral_blade_tip_diameter = fields.Float('整体式刀具刀尖直径(mm)', digits=(6, 1)) + integral_blade_tip_taper = fields.Float('整体式刀具刀尖锥度(°)', digits=(6, 1)) + integral_blade_helix_angle = fields.Float('整体式刀具刃部螺旋角(°)', digits=(6, 1)) + integral_blade_type = fields.Selection([('直刃', '直刃'), ('带断屑槽', '带断屑槽')], '整体式刀具刃部类型') + integral_coarse_medium_fine = fields.Selection([('粗', '粗'), ('中', '中'), ('精', '精')], '整体式刀具粗/中/精') + integral_blade_material = fields.Selection([('碳素钢', '碳素钢'), ('硬质合金', '硬质合金')], '整体式刀具刀具材质') + integral_hardness = fields.Integer('整体式刀具硬度(HRC)') integral_coating_material = fields.Char('整体式刀具涂层材质') - integral_nut = fields.Float('整体式刀具配对螺母(mm)') - integral_scope = fields.Char('整体式刀具适用范围') + integral_run_out_accuracy_max = fields.Float('整体式刀具端跳精度max', digits=(6,1)) + integral_run_out_accuracy_min = fields.Float('整体式刀具端跳精度min', digits=(6, 1)) + + @api.constrains('integral_total_length') + def _check_integral_total_length(self): + if self.integral_total_length <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("总长度不能为0") + + @api.constrains('integral_shank_length') + def _check_integral_shank_length(self): + if self.integral_shank_length <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("柄部长度不能为0") + + @api.constrains('integral_blade_length') + def _check_integral_blade_length(self): + if self.integral_blade_length <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("刃部长度不能为0") + + @api.constrains('integral_blade_number') + def _check_integral_blade_number(self): + if self.integral_blade_number <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("刃数不能为0") + + @api.constrains('integral_shank_diameter') + def _check_integral_shank_diameter(self): + if self.integral_shank_diameter <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("柄部直径不能为0") + + @api.constrains('integral_blade_diameter') + def _check_integral_blade_diameter(self): + if self.integral_blade_diameter <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("刃部直径不能为0") + + @api.constrains('integral_run_out_accuracy_min') + def _check_integral_blade_diameter(self): + if self.integral_run_out_accuracy_min <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("端跳精度最小(min)不能为0") + + @api.constrains('integral_run_out_accuracy_max') + def _check_integral_run_out_accuracy_max(self): + if self.integral_run_out_accuracy_max <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("端跳精度最大(max)不能为0") + + # integral_front_angle = fields.Float('整体式刀具前角(°)') + # integral_rear_angle = fields.Float('整体式刀具后角(°)') + # integral_main_included_angle = fields.Float('整体式刀具主偏角(°)') + # integral_accuracy = fields.Float('整体式刀具精度等级') + # integral_hardness = fields.Float('整体式刀具加工硬度(HRC)') + # integral_coating_material = fields.Char('整体式刀具涂层材质') + # integral_nut = fields.Float('整体式刀具配对螺母(mm)') + # integral_scope = fields.Char('整体式刀具适用范围') # 刀杆特有字段 bar_code = fields.Char('刀杆编码', readonly=True) @@ -193,4 +248,3 @@ class SfToolMaterialSearch(models.Model): warehouse_area = fields.Char('库区') warehouse_location = fields.Char('库位') three_d_model = fields.Many2one('ir.attachment', '3D模型') - diff --git a/sf_tool_management/views/tool_material_search.xml b/sf_tool_management/views/tool_material_search.xml index c8e0a55c..0e1c5b0b 100644 --- a/sf_tool_management/views/tool_material_search.xml +++ b/sf_tool_management/views/tool_material_search.xml @@ -6,7 +6,7 @@ sf.tool.material.search - + @@ -33,19 +33,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -134,13 +134,13 @@ - + + - - + @@ -195,18 +195,32 @@ - - - + + + + + + + + + + (mm) + + + (mm) + - - - - - + + + + + + + -