产品新增适配刀片形状,适合加工方式,刀尖特征,走刀方向,柄部类型,冷却液,压紧方式验证

This commit is contained in:
jinling.yang
2023-11-17 17:45:41 +08:00
parent e5b0960e3a
commit 49f021ed7a

View File

@@ -204,16 +204,6 @@ class ResProductMo(models.Model):
self.cutting_tool_blade_depth = self.specification_id.blade_depth
self.cutting_tool_cut_depth = self.specification_id.cutting_depth
self.cutting_speed_ids = self.cutting_tool_model_id.cutting_speed_ids
# # self.feed_per_tooth_ids = self.cutting_tool_model_id.feed_per_tooth_ids.
# for tooth in self.cutting_tool_model_id.feed_per_tooth_ids:
# print(int(tooth.blade_diameter))
# print(int(self.specification_id.blade_diameter))
# if int(tooth.blade_diameter) == int(self.specification_id.blade_diameter):
# self.feed_per_tooth_ids = [(0, 0, {
# 'cutting_speed': tooth.cutting_speed,
# 'machining_method': tooth.machining_method,
# 'blade_diameter': tooth.blade_diameter,
# 'materials_type_id': tooth.materials_type_id.id})]
self.feed_per_tooth_ids = self.cutting_tool_model_id.feed_per_tooth_ids.filtered(
lambda r: int(r.blade_diameter) == int(self.specification_id.blade_diameter))
elif self.cutting_tool_type == '夹头':
@@ -358,89 +348,33 @@ class ResProductMo(models.Model):
self.cutting_speed_ids = False
self.feed_per_tooth_ids = False
# @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('cutting_tool_total_length')
# def _check_cutting_tool_total_length(self):
# if self.cutting_tool_total_length <= 0 and self.cutting_tool_type == '整体式刀具':
# raise ValidationError("总长度不能为0")
#
# @api.constrains('cutting_tool_shank_length')
# def _check_cutting_tool_shank_length(self):
# if self.cutting_tool_shank_length <= 0 and self.cutting_tool_type == '整体式刀具':
# raise ValidationError("柄部长度不能为0")
#
# @api.constrains('cutting_tool_blade_length')
# def _check_cutting_tool_blade_length(self):
# if self.cutting_tool_blade_length <= 0 and self.cutting_tool_type == '整体式刀具':
# raise ValidationError("刃部长度不能为0")
#
# @api.constrains('cutting_tool_blade_number')
# def _check_cutting_tool_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('fit_blade_shape_id', 'suitable_machining_method_ids', 'blade_tip_characteristics_id',
'handle_type_ids', 'cutting_direction_ids', 'suitable_coolant_ids', 'compaction_way_ids')
def _check_cutting_tool_ability(self):
if self.cutting_tool_type in ['整体式刀具', '刀片', '刀杆', '刀盘']:
if self.cutting_tool_type in ['刀片', '刀杆', '刀盘']:
if not self.fit_blade_shape_id:
raise ValidationError("请选择适配刀片形状")
if self.cutting_tool_type in ['刀杆', '刀盘']:
if not self.compaction_way_ids:
raise ValidationError("请选择压紧方式")
if self.cutting_tool_type == '刀片':
if not self.suitable_coolant_ids:
raise ValidationError("请选择适合冷却液")
elif self.cutting_tool_type == '整体式刀具':
if not self.handle_type_ids:
raise ValidationError("请选择柄部类型")
if not self.suitable_coolant_ids:
raise ValidationError("请选择适合冷却液")
if not self.suitable_machining_method_ids:
raise ValidationError("请选择适合加工方式")
if not self.blade_tip_characteristics_id:
raise ValidationError("请选择刀尖特征")
if not self.cutting_direction_ids:
raise ValidationError("请选择走刀方向")
cutting_speed_ids = fields.One2many('sf.cutting.speed', 'product_template_id', string='切削速度Vc')
feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'product_template_id', string='每齿走刀量fz')
# @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('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_rear_angle = fields.Integer('后角(°)')
cutting_tool_main_included_angle = fields.Integer('主偏角(°)')
@@ -758,26 +692,19 @@ class ResProductMo(models.Model):
'model_file': '' if not item['model_file'] else base64.b64decode(item['model_file']),
'model_name': attachment.name,
'upload_model_file': [(6, 0, [attachment.id])],
# 'tag_ids': [(6, 0, [t.id for t in account_template.tag_ids])],
# 'single_manufacturing': True,
# 'tracking': 'serial',
'list_price': item['price'],
# 'categ_id': self.env.ref('sf_dlm.product_category_finished_sf').id,
'materials_id': self.env['sf.production.materials'].search(
[('materials_no', '=', item['texture_code'])]).id,
'materials_type_id': self.env['sf.materials.model'].search(
[('materials_no', '=', item['texture_type_code'])]).id,
# 'model_surface_process_ids': self.get_production_process_id(item['surface_process_code']),
'model_process_parameters_ids': [(6, 0, [])] if not item.get(
'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']),
'model_remark': item['remark'],
'default_code': '%s-%s' % (order_number, i),
# 'barcode': item['barcode'],
'active': True,
# 'route_ids': self._get_routes('')
}
copy_product_id.sudo().write(vals)
# product_id.product_tmpl_id.active = False
product_id.product_tmpl_id.active = False
return copy_product_id
def _get_ids(self, param):
@@ -833,12 +760,6 @@ class ResProductMo(models.Model):
'materials_id': materials_id.id,
'materials_type_id': materials_type_id.id,
'is_bfm': True,
# 'route_ids': self._get_routes(route_type),
# 'categ_id': self.env.ref('sf_dlm.product_category_embryo_sf').id,
# 'model_surface_process_id': self.env['sf.production.process'].search(
# [('process_encode', '=', item['surface_process_code'])]).id,
# 'model_process_parameters_id': self.env['sf.processing.technology'].search(
# [('process_encode', '=', item['process_parameters_code'])]).id,
'active': True
}
# 外协和采购生成的坯料需要根据材料型号绑定供应商
@@ -850,8 +771,6 @@ class ResProductMo(models.Model):
partner = self.env['res.partner'].search([('id', '=', supplier.partner_id.id)])
partner.is_subcontractor = True
no_bom_copy_product_id.write(vals)
logging.info('no_bom_copy_product_id-vals:%s' % vals)
# product_id.product_tmpl_id.active = False
return no_bom_copy_product_id
@api.model_create_multi