diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index d904f869..58cc0cf6 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -503,32 +503,21 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False) # res_partner_id = fields.Many2one('res.partner', '智能工厂', domain="[('is_factory', '=', True)]") - @api.depends('after_assembly_functional_tool_type_id', 'integral_specification_id', 'bar_specification_id', - 'pad_specification_id', 'handle_specification_id', 'after_assembly_tool_loading_length') + @api.depends('after_assembly_functional_tool_type_id', 'cutting_tool_cutterhandle_model_id', + 'after_assembly_functional_tool_diameter', 'after_assembly_tool_loading_length', + 'after_assembly_knife_tip_r_angle', 'after_assembly_functional_tool_length', + 'after_assembly_handle_length') def _compute_code(self): for obj in self: - str_1 = 'GNDJ-%s' % obj.after_assembly_functional_tool_type_id.code - str_2 = '' - if obj.handle_specification_id: - if obj.integral_specification_id: - str_2 = '%s-D%sL%sB%sH%s-' % ( - str_1, obj.integral_specification_id.blade_diameter, obj.after_assembly_tool_loading_length, - obj.integral_specification_id.blade_length, obj.handle_specification_id.total_length) - elif obj.bar_specification_id: - str_2 = '%s-D%sL%sB%sH%s-' % ( - str_1, obj.bar_specification_id.cutter_arbor_diameter, obj.after_assembly_tool_loading_length, - obj.bar_specification_id.blade_length, obj.handle_specification_id.total_length) - elif obj.pad_specification_id: - str_2 = '%s-D%sL%sB%sH%s-' % ( - str_1, obj.pad_specification_id.cutter_head_diameter, obj.after_assembly_tool_loading_length, - obj.pad_specification_id.cut_depth_max, obj.handle_specification_id.total_length, - ) - else: - obj.code = str_2 - return True - obj.code = str_2 + str(self._get_code(str_2)) + if obj.cutting_tool_cutterhandle_model_id: + code = obj.cutting_tool_cutterhandle_model_id.code.split('-', 1)[0] + str_1 = '%s-GNDJ-%s-D%sL%sR%sB%sH%s' % ( + code, obj.after_assembly_functional_tool_type_id.code, obj.after_assembly_functional_tool_diameter, + obj.after_assembly_tool_loading_length, obj.after_assembly_knife_tip_r_angle, + round(obj.after_assembly_functional_tool_length, 3), obj.after_assembly_handle_length) + obj.code = '%s-%s' % (str_1, self._get_code(str_1)) else: - obj.code = str_2 + obj.code = '' def _get_code(self, str_2): functional_tool_assembly = self.env['sf.functional.cutting.tool.entity'].sudo().search(