From d9115333bfdc75cdcf21f47ef7a3b8913ce91618 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Wed, 17 Jan 2024 17:30:16 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96CAM=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E7=A8=8B=E5=BA=8F=E7=94=A8=E5=88=80=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=A4=A7=E9=87=8F?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=EF=BC=8C=E4=BC=98=E5=8C=96tree=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E5=8F=8Aform=E8=A7=86=E5=9B=BE=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=8F=8A=E5=85=B6=E5=B8=83=E5=B1=80=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0CAM=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=92=8C=E6=92=A4=E9=94=80=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=8F=8A=E5=85=B6=E6=8C=89=E9=92=AE=EF=BC=9B3=E3=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=B9=E6=8D=AE=E5=88=80=E5=85=B7=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=92=8C=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0=E6=A3=80?= =?UTF-8?q?=E7=B4=A2=E7=8E=B0=E6=9C=89=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=BB=A1=E8=B6=B3=E9=9C=80=E6=B1=82=EF=BC=8C?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E4=B8=8D=E6=BB=A1=E8=B6=B3=E5=88=99=E5=88=9B?= =?UTF-8?q?=E5=BB=BACAM=E5=B7=A5=E5=8D=95=E7=A8=8B=E5=BA=8F=E7=94=A8?= =?UTF-8?q?=E5=88=80=E8=AE=A1=E5=88=92=E8=AE=B0=E5=BD=95=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=8E=A5=E5=8F=A3(=E8=BF=9B=E8=A1=8C=E4=B8=AD)?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 69 +++++++--- sf_tool_management/views/tool_base_views.xml | 128 +++++++++++-------- 2 files changed, 125 insertions(+), 72 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 39805f58..97447936 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -594,16 +594,16 @@ class CAMWorkOrderProgramKnifePlan(models.Model): _name = 'sf.cam.work.order.program.knife.plan' _description = 'CAM工单程序用刀计划' - name = fields.Char(string='工单任务编号', readonly=False) - cam_procedure_code = fields.Char(string='CAM程序编号', readonly=False) - cam_cutter_spacing_code = fields.Char(string='CAM刀位号', readonly=False) + name = fields.Char('工单任务编号') + cam_procedure_code = fields.Char('程序名') + filename = fields.Char('文件') + cam_cutter_spacing_code = fields.Char('刀号') tool_position_interface_type = fields.Selection( [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), ('直装固定式', '直装固定式')], string='刀位接口型号') - production_line_id = fields.Many2one('sf.production.line', string='生产线', readonly=False, - group_expand='_read_group_names') - machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=False, + production_line_id = fields.Many2one('sf.production.line', string='生产线', group_expand='_read_group_names') + machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', domain="[('production_line_id', '=', production_line_id)]") machine_table_name = fields.Char(string='机台号', readonly=True, related='machine_table_name_id.name') cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', required=True, @@ -616,8 +616,9 @@ class CAMWorkOrderProgramKnifePlan(models.Model): barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', domain=[('product_id.name', '=', '功能刀具')]) - functional_tool_name = fields.Char(string='功能刀具名称', required=True) + functional_tool_name = fields.Char(string='功能刀具名称', compute='_compute_functional_tool_name') functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False) + tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组') diameter = fields.Integer(string='刀具直径(mm)', readonly=False) tool_included_angle = fields.Float(string='刀尖R角(mm)', readonly=False) tool_loading_length = fields.Float(string='总长度(mm)', readonly=False) @@ -629,12 +630,28 @@ class CAMWorkOrderProgramKnifePlan(models.Model): L_D = fields.Float(string='L/D值', readonly=False) clearance_length = fields.Float(string='避空长(mm)', readonly=False) required_cutting_time = fields.Integer(string='需切削时长', readonly=False) + process_type = fields.Char('加工类型') + margin_x_y = fields.Float('余量_X/Y') + margin_z = fields.Float('余量_Z') + finish_depth = fields.Float('加工深度') + shank_model = fields.Char('刀柄型号') + estimated_processing_time = fields.Char('预计加工时间') plan_execute_status = fields.Selection([('0', '待下发'), ('1', '执行中'), ('2', '已完成')], string='计划执行状态', default='0', readonly=False) sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True) + @api.depends('diameter', 'tool_included_angle', 'tool_groups_id') + def _compute_functional_tool_name(self): + for obj in self: + if obj.tool_groups_id: + obj.functional_tool_name = '%s-D%sR%s' % ( + obj.tool_groups_id.name, obj.diameter, + obj.tool_included_angle) + else: + obj.functional_tool_name = None + @api.model def _read_group_names(self, categories, domain, order): names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) @@ -646,27 +663,34 @@ class CAMWorkOrderProgramKnifePlan(models.Model): :return: """ record = self.env['sf.functional.tool.assembly'].create({ - 'barcode_id': self.barcode_id.id, - 'functional_tool_name_id': self.functional_tool_name_id.id, + 'functional_tool_name': self.functional_tool_name, 'functional_tool_type_id': self.functional_tool_type_id.id, + 'tool_groups_id': self.tool_groups_id.id, 'functional_tool_diameter': self.diameter, - 'functional_tool_length': self.tool_loading_length, - 'loading_task_source': '0', - 'coarse_middle_thin': None, - 'tool_loading_length': None, - 'applicant': self.env.user.name, - 'reason_for_applying': self.reason_for_applying, - 'use_tool_time': self.need_knife_time, + 'knife_tip_r_angle': self.tool_included_angle, + 'tool_loading_length': self.tool_loading_length, + 'functional_tool_length': self.extension_length, + 'effective_length': self.effective_length, + 'whether_standard_knife': self.whether_standard_knife, + 'coarse_middle_thin': self.coarse_middle_thin, + 'new_former': self.new_former, + 'production_line_name_id': self.production_line_id.id, 'machine_tool_name_id': self.machine_table_name_id.id, - 'machine_tool_code': self.cam_procedure_code, - 'cutter_spacing_code': self.cam_cutter_spacing_code, + 'cutter_spacing_code_id': self.env['maintenance.equipment.tool'].sudo().search( + [('code', '=', self.cam_cutter_spacing_code), ('equipment_id', '=', self.machine_table_name_id.id)]).id, + + 'loading_task_source': '0', + 'applicant': self.env.user.name, + 'use_tool_time': self.need_knife_time, + 'reason_for_applying': '工单用刀', + 'sf_cam_work_order_program_knife_plan_id': self.id }) self.sf_functional_tool_assembly_id = record.id # 将计划执行状态改为执行中 self.env['sf.cam.work.order.program.knife.plan'].search( - [('barcode_id', '=', self.barcode_id.id)]).write( + [('name', '=', self.name), ('functional_tool_name', '=', self.functional_tool_name)]).write( {'plan_execute_status': '1', 'applicant': self.env.user.name}) @@ -676,16 +700,19 @@ class CAMWorkOrderProgramKnifePlan(models.Model): :return: """ self.env['sf.functional.tool.assembly'].search( - [('barcode_id', '=', self.barcode_id.id), + [('assembly_order_code', '=', self.sf_functional_tool_assembly_id.assembly_order_code), ('loading_task_source', '=', '0')]).unlink() # 将计划执行状态改为待执行,同时清除申请人、功能刀具组装字段数据 self.env['sf.cam.work.order.program.knife.plan'].search( - [('barcode_id', '=', self.barcode_id.id)]).write( + [('name', '=', self.name), ('functional_tool_name', '=', self.functional_tool_name)]).write( {'plan_execute_status': '0', 'applicant': None, 'sf_functional_tool_assembly_id': None}) + def create_cam_work_plan(self, **kw): + pass + class FunctionalToolAssembly(models.Model): _name = 'sf.functional.tool.assembly' diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index dd8e3bf0..fb8b3a5e 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -756,21 +756,29 @@ + + + + + + + + + + + + + + + - - - - - - - - - - - - + +