From a6ddfa22a18e5e0d2832b15a204f583096cb014a Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Tue, 5 Sep 2023 17:21:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E4=BA=A7=E5=93=81=E7=9A=84=E6=95=B4?= =?UTF-8?q?=E4=BD=93=E5=BC=8F=E5=88=80=E5=85=B7=E8=83=BD=E5=8A=9B=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=BF=9B=E8=A1=8C=E8=A1=A5=E5=85=85=EF=BC=8C=E5=AF=B9?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=AD=97=E6=AE=B5=E8=BF=9B=E8=A1=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=9B=E5=AF=B9=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=9A=84=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=B0=83=E6=95=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_dlm/views/product_template_view.xml | 137 +++++++++--------- sf_manufacturing/models/product_template.py | 106 +++++++++++++- .../models/tool_material_search.py | 4 +- .../views/tool_material_search.xml | 4 +- 4 files changed, 171 insertions(+), 80 deletions(-) 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 @@ - +