diff --git a/sf_dlm/views/product_template_view.xml b/sf_dlm/views/product_template_view.xml index bfe1e4d5..c7622563 100644 --- a/sf_dlm/views/product_template_view.xml +++ b/sf_dlm/views/product_template_view.xml @@ -83,77 +83,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - + attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀柄'))]}"/> + + + + + + + + + + + + + + + + attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀片'))]}"/> @@ -231,6 +194,38 @@ attrs="{'invisible': [('cutting_tool_type', 'not in', ('刀片'))]}"/> + + + + + + + + + + + + + + + + + + + + + diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index dbeb7814..01471a52 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -74,12 +74,108 @@ class ResProductMo(models.Model): tool_weight = fields.Float('重量(kg)') coating_material = fields.Char('涂层材质') - # 整体式刀具参数 - cutting_tool_total_length = fields.Float('总长度(mm)') - cutting_tool_shank_length = fields.Float('柄部长度(mm)') - cutting_tool_blade_length = fields.Float('刃部长度(mm)') + # 整体式刀具特有字段 + cutting_tool_total_length = fields.Float('总长度(mm)', digits=(6, 1)) + cutting_tool_shank_length = fields.Float('柄部长度(mm)', digits=(6, 1)) + cutting_tool_blade_length = fields.Float('刃部长度(mm)', digits=(6, 1)) + cutting_tool_blade_number = fields.Integer('刃数(个)') + # 整体式刀具新增字段 + integral_code = fields.Char('整体式刀具编码', readonly=True) + 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_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.Char('整体式刀具刃部类型') + integral_coarse_medium_fine = fields.Selection([('粗', '粗'), ('中', '中'), ('精', '精')], '整体式刀具粗/中/精') + integral_hardness = fields.Integer('整体式刀具硬度(HRC)') + integral_run_out_accuracy_max = fields.Float('整体式刀具端跳精度max', digits=(6, 1)) + integral_run_out_accuracy_min = fields.Float('整体式刀具端跳精度min', digits=(6, 1)) + suitable_machining_method_ids = fields.Many2many('sf.suitable.machining.method', + 'rel_suitable_machining_method_product_template', '适合加工方式') + blade_tip_characteristics_ids = fields.Many2many('sf.blade.tip.characteristics', + 'rel_blade_tip_characteristics_product_template', '刀尖特征') + handle_type_ids = fields.Many2many('sf.handle.type', 'rel_handle_type_product_template', '柄部类型') + cutting_direction_ids = fields.Many2many('sf.cutting.direction', 'rel_cutting_direction_product_template', '走刀方向') + suitable_coolant_ids = fields.Many2many('sf.suitable.coolant', 'rel_suitable_coolant_product_template', '适合冷却液') + + @api.constrains('suitable_machining_method_ids') + def _check_suitable_machining_method_ids(self): + for record in self: + if len(record.suitable_machining_method_ids) == 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("适合加工方式不能为空!") + + @api.constrains('blade_tip_characteristics_ids') + def _check_blade_tip_characteristics_ids(self): + for record in self: + if len(record.blade_tip_characteristics_ids) == 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("刀尖特征不能为空!") + if len(record.blade_tip_characteristics_ids) > 1 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("刀尖特征只能单选!") + + @api.constrains('handle_type_ids') + def _check_handle_type_ids(self): + for record in self: + if len(record.handle_type_ids) == 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("柄部类型不能为空!") + if len(record.handle_type_ids) > 1 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("柄部类型只能单选!") + + @api.constrains('cutting_direction_ids') + def _check_cutting_direction_ids(self): + for record in self: + if len(record.cutting_direction_ids) == 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("走刀方向不能为空!") + + @api.constrains('suitable_coolant_ids') + def _check_suitable_coolant_ids(self): + for record in self: + if not record.suitable_coolant_ids and self.cutting_tool_type == '整体式刀具': + raise ValidationError("适合冷却液不能为空!") + + @api.constrains('integral_total_length') + def _check_integral_total_length(self): + if self.cutting_tool_total_length <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("总长度不能为0") + + @api.constrains('integral_shank_length') + def _check_integral_shank_length(self): + if self.cutting_tool_shank_length <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("柄部长度不能为0") + + @api.constrains('integral_blade_length') + def _check_integral_blade_length(self): + if self.cutting_tool_blade_length <= 0 and self.cutting_tool_type == '整体式刀具': + raise ValidationError("刃部长度不能为0") + + @api.constrains('integral_blade_number') + def _check_integral_blade_number(self): + if self.cutting_tool_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") + cutting_tool_diameter = fields.Float('直径(mm)') - cutting_tool_blade_number = fields.Integer('刃数') cutting_tool_front_angle = fields.Float('前角(°)') cutting_tool_rear_angle = fields.Float('后角(°)') cutting_tool_main_included_angle = fields.Float('主偏角(°)') diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py index f75d7e08..c58d0e6f 100644 --- a/sf_tool_management/models/tool_material_search.py +++ b/sf_tool_management/models/tool_material_search.py @@ -86,9 +86,9 @@ class SfToolMaterialSearch(models.Model): 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_blade_type = fields.Char('整体式刀具刃部类型') integral_coarse_medium_fine = fields.Selection([('粗', '粗'), ('中', '中'), ('精', '精')], '整体式刀具粗/中/精') - integral_blade_material = fields.Selection([('碳素钢', '碳素钢'), ('硬质合金', '硬质合金')], '整体式刀具刀具材质') + # integral_blade_material = fields.Selection([('碳素钢', '碳素钢'), ('硬质合金', '硬质合金')], '整体式刀具刀具材质') integral_hardness = fields.Integer('整体式刀具硬度(HRC)') integral_coating_material = fields.Char('整体式刀具涂层材质') integral_run_out_accuracy_max = fields.Float('整体式刀具端跳精度max', digits=(6,1)) diff --git a/sf_tool_management/views/tool_material_search.xml b/sf_tool_management/views/tool_material_search.xml index 4bb4bf03..7ed97d1d 100644 --- a/sf_tool_management/views/tool_material_search.xml +++ b/sf_tool_management/views/tool_material_search.xml @@ -139,7 +139,7 @@ - + @@ -200,7 +200,7 @@ - +