From 29a55f3ff888fd167a5a9ae121d1902c6cce29c1 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 4 Dec 2023 17:30:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=88=9B=E5=BB=BA=E5=88=80=E4=BD=8D=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=88=9B=E5=BB=BA=E5=AF=B9=E5=BA=94=E5=88=80=E4=BD=8D?= =?UTF-8?q?=E7=9A=84=E6=9C=BA=E5=BA=8A=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=9B2=E3=80=81=E6=9C=BA=E5=BA=8A?= =?UTF-8?q?=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E6=A8=A1=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E3=80=81=E5=88=80=E4=BD=8D=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=8F=AA=E8=AF=BB=EF=BC=8C=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E8=A7=86=E5=9B=BE=E6=96=B0=E5=A2=9E=E6=8C=89=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=90=9C=E7=B4=A2=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 18 ++++++++++++++---- sf_tool_management/models/base.py | 18 ++++++++++-------- sf_tool_management/views/tool_base_views.xml | 7 ++++--- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 124e0058..bed75e6d 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -88,19 +88,19 @@ class ResProductMo(models.Model): cutting_tool_run_out_accuracy_min = fields.Float('端跳精度min', digits=(6, 1)) cutting_tool_blade_tip_working_size = fields.Char('刀尖处理尺寸(R半径mm/倒角)', size=20) fit_blade_shape_id = fields.Many2one('maintenance.equipment.image', - '适配刀片形状', domain=[('type', '=', '刀片形状')]) + '适配刀片形状', domain=[('type', '=', '刀片形状')]) suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image', 'rel_machining_product_template', '适合加工方式', domain=[('type', '=', '加工能力')]) blade_tip_characteristics_id = fields.Many2one('maintenance.equipment.image', '刀尖特征', - domain=[('type', '=', '刀尖特征')]) - handle_type_id = fields.Many2one('maintenance.equipment.image', '柄部类型',domain=[('type', '=', '柄部类型')]) + domain=[('type', '=', '刀尖特征')]) + handle_type_id = fields.Many2one('maintenance.equipment.image', '柄部类型', domain=[('type', '=', '柄部类型')]) cutting_direction_ids = fields.Many2many('maintenance.equipment.image', 'rel_cutting_product_template', '走刀方向', domain=[('type', '=', '走刀方向')]) suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'rel_coolant_product_template', '适合冷却液', domain=[('type', '=', '冷却液')]) compaction_way_id = fields.Many2one('maintenance.equipment.image', - '压紧方式', domain=[('type', '=', '压紧方式')]) + '压紧方式', domain=[('type', '=', '压紧方式')]) @api.onchange('cutting_tool_material_id') def _onchange_cutting_tool_material_id(self): @@ -873,3 +873,13 @@ class SfMaintenanceEquipmentTool(models.Model): for record in self: if record.code: record.name = record.code + + @api.model_create_multi + def create(self, vals_list): + tools = super().create(vals_list) + for tool in tools: + self.env['sf.machine.table.tool.changing.apply'].sudo().create({ + 'maintenance_equipment_id': tool.equipment_id.id, + 'cutter_spacing_code_id': tool.id + }) + return tools diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index b5e62d6e..101f9049 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -42,10 +42,12 @@ class FunctionalCuttingToolEntity(models.Model): # 计算库存位置数量 # """ # for obj in self: - # if obj.current_location_id.name in ('组装后', '刀具房'): - # obj.tool_room_num = 1 - # obj.line_edge_knife_library_num = 0 - # obj.machine_knife_library_num = 0 + # if obj.current_location_id: + # if obj.current_location_id.name in ('组装后', '刀具房'): + # obj.tool_room_num = 1 + # obj.line_edge_knife_library_num = 0 + # obj.machine_knife_library_num = 0 + # @api.model def _read_group_mrs_cutting_tool_type_id(self, categories, domain, order): @@ -258,14 +260,14 @@ class MachineTableToolChangingApply(models.Model): name = fields.Char('名称', related='maintenance_equipment_id.name', store=True) # 设备信息 - maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床', required=True, readonly=False, + maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床', readonly=True, domain=[('category_id.equipment_type', '=', '机床')]) production_line_id = fields.Many2one('sf.production.line', string='生产线', readonly=True, group_expand='_read_group_names') machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型', readonly=True, compute='_compute_machine_table_type_id') machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True) - cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=False, + cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True, required=True, domain="[('equipment_id', '=', maintenance_equipment_id)]") # 功能刀具信息 functional_tool_name = fields.Char(string='刀具名称', related='functional_tool_name_id.name', store=True) @@ -279,7 +281,7 @@ class MachineTableToolChangingApply(models.Model): tool_position_interface_type = fields.Selection( [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), - ('直装固定式', '直装固定式')], string='刀位接口型号', required=True) + ('直装固定式', '直装固定式')], string='刀位接口型号') diameter = fields.Integer(string='刀具直径(mm)', ) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') max_lifetime_value = fields.Integer(string='最大寿命值(min)') @@ -305,7 +307,7 @@ class MachineTableToolChangingApply(models.Model): @api.depends('alarm_value', 'used_value') def _compute_functional_tool_status(self): for record in self: - if record.alarm_value <= record.used_value: + if record.alarm_value < record.used_value: record.functional_tool_status = '报警' else: record.functional_tool_status = '正常' diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 6e2258e5..745edac7 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -634,15 +634,15 @@

- +

- - + + @@ -698,6 +698,7 @@ + From 0d8d54c05be8a957453facdc6be8b511a1bacbc9 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 5 Dec 2023 17:37:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E6=9C=BA=E5=BA=8A=E6=8D=A2?= =?UTF-8?q?=E5=88=80=E7=94=B3=E8=AF=B7=E6=96=B0=E5=A2=9E=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E6=8D=A2=E5=88=80=E6=97=B6=EF=BC=8C=E4=BE=9D=E6=AC=A1=E6=A3=80?= =?UTF-8?q?=E7=B4=A2=E7=BA=BF=E8=BE=B9=E5=88=80=E5=BA=93=E3=80=81=E5=88=80?= =?UTF-8?q?=E5=85=B7=E6=88=BF=E6=98=AF=E5=90=A6=E6=9C=89=E6=BB=A1=E8=B6=B3?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E7=9A=84=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=9C=89=E5=B0=B1=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=88=80=E5=85=B7=E4=BF=A1=E6=81=AF=EF=BC=8C=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=B0=B1=E5=8F=91=E8=B5=B7=E7=BB=84=E8=A3=85=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=EF=BC=9B2=E3=80=81=E5=88=80=E5=85=B7=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=A8=A1=E5=9E=8B=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8F=AF=E4=BF=AE=E6=94=B9=E7=9A=84=E6=9C=80?= =?UTF-8?q?=E4=BD=8E=E5=BA=93=E5=AD=98=E9=87=8F=E3=80=81=E6=9C=80=E9=AB=98?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E9=87=8F=E3=80=81=E6=89=B9=E6=AC=A1=E8=A1=A5?= =?UTF-8?q?=E8=B4=A7=E9=87=8F=E5=AD=97=E6=AE=B5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 24 ++++++- sf_tool_management/views/tool_base_views.xml | 31 +++++---- sf_tool_management/wizard/wizard.py | 70 ++++++++++++-------- 3 files changed, 81 insertions(+), 44 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 101f9049..92242197 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -232,7 +232,13 @@ class RealTimeDistributionOfFunctionalTools(models.Model): def _compute_tool_stock_total(self): for record in self: if record: - self.tool_stock_total = record.tool_stock_num + record.side_shelf_num + record.on_tool_stock_num + record.tool_stock_total = record.tool_stock_num + record.side_shelf_num + record.on_tool_stock_num + + # @api.depends('tool_stock_total', 'min_stock_num', 'max_stock_num') + # def _compute_batch_replenishment_num(self): + # for record in self: + # if record.tool_stock_total < record.min_stock_num: + # record.batch_replenishment_num = record.max_stock_num - record.tool_stock_total def create_or_edit_safety_stock(self, vals, sf_functional_cutting_tool_entity_ids): """ @@ -365,7 +371,7 @@ class MachineTableToolChangingApply(models.Model): 'use_tool_time': fields.Datetime.now() + timedelta(hours=4), 'production_line_name_id': self.production_line_id.id, 'machine_tool_name_id': self.maintenance_equipment_id.id, - 'applicant': self.applicant, + 'applicant': '系统自动', 'apply_time': fields.Datetime.now(), 'cutter_spacing_code_id': self.cutter_spacing_code_id.id, 'whether_standard_knife': self.whether_standard_knife, @@ -687,6 +693,20 @@ class FunctionalToolAssembly(models.Model): code = False return code + def get_functional_tool(self, val): + functional_tools = self.env['sf.functional.tool.assembly'].search( + [('after_assembly_functional_tool_name', '=', val.get('after_assembly_functional_tool_name')), + ('after_assembly_functional_tool_diameter', '=', val.get('after_assembly_functional_tool_diameter')), + ('after_assembly_knife_tip_r_angle', '=', val.get('after_assembly_knife_tip_r_angle')), + ('after_assembly_coarse_middle_thin', '=', val.get('after_assembly_coarse_middle_thin'))]) + for functional_tool in functional_tools: + if functional_tool.barcode_id.quant_ids[-1].location_id.name == '刀具线边库': + return functional_tool + for functional_tool in functional_tools: + if functional_tool.barcode_id.quant_ids[-1].location_id.name == '刀具房': + return functional_tool + return False + def automated_assembly(self): """ todo 自动组装 diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 745edac7..a5e09fb8 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -301,7 +301,7 @@ 功能刀具安全库存 sf.real.time.distribution.of.functional.tools -
+

@@ -310,41 +310,44 @@

- - - - - + + + + + + + + - + - - @@ -352,7 +355,7 @@ - + @@ -468,7 +471,7 @@ 机床换刀申请 sf.machine.table.tool.changing.apply - + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 2c81cb31..b072ec2c 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -62,33 +62,47 @@ class ToolChangeRequirementInformation(models.TransientModel): ('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id) ]) - # 功能刀具组装创建新任务(new_assembly_task) - sf_functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().create({ - 'functional_tool_name': self.replacement_tool_name, - 'functional_tool_type_id': self.replacement_tool_type_id.id, - 'functional_tool_diameter': self.replacement_diameter, - 'knife_tip_r_angle': self.replacement_knife_tip_r_angle, - 'coarse_middle_thin': self.replacement_tool_coarse_middle_thin, - 'new_former': self.new_former, - 'tool_loading_length': self.replacement_tool_setting_length, - 'functional_tool_length': self.replacement_extension_length, - 'effective_length': self.replacement_effective_length, - 'loading_task_source': '1', - 'use_tool_time': self.used_tool_time, - 'production_line_name_id': self.production_line_id.id, - 'machine_tool_name_id': self.maintenance_equipment_id.id, - 'applicant': self.applicant, - 'apply_time': fields.Datetime.now(), - 'cutter_spacing_code_id': self.cutter_spacing_code_id.id, - 'whether_standard_knife': self.whether_standard_knife, - 'reason_for_applying': self.reason_for_applying, - 'sf_machine_table_tool_changing_apply_id': record.id - }) - # 修改机床换刀申请状态 - record.write({ - 'status': '1', - 'sf_functional_tool_assembly_id': sf_functional_tool_assembly.id + # 搜索满足需求的功能刀具 + functional_tool = self.env['sf.functional.tool.assembly'].get_functional_tool({ + 'after_assembly_functional_tool_name': self.replacement_tool_name, + 'after_assembly_functional_tool_diameter': self.replacement_diameter, + 'after_assembly_knife_tip_r_angle': self.replacement_knife_tip_r_angle, + 'after_assembly_coarse_middle_thin': self.replacement_tool_coarse_middle_thin }) + # 如果有满足需求的刀具,就返回刀具信息 + if functional_tool: + record.write({'status': '3'}) + # todo 将功能刀具信息传递到机床 + return functional_tool + # 如果没有满足需求的刀具,就创建功能刀具组装单 + else: + # 功能刀具组装创建新任务(new_assembly_task) + sf_functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().create({ + 'functional_tool_name': self.replacement_tool_name, + 'functional_tool_type_id': self.replacement_tool_type_id.id, + 'functional_tool_diameter': self.replacement_diameter, + 'knife_tip_r_angle': self.replacement_knife_tip_r_angle, + 'coarse_middle_thin': self.replacement_tool_coarse_middle_thin, + 'new_former': self.new_former, + 'tool_loading_length': self.replacement_tool_setting_length, + 'functional_tool_length': self.replacement_extension_length, + 'effective_length': self.replacement_effective_length, + 'loading_task_source': '1', + 'use_tool_time': self.used_tool_time, + 'production_line_name_id': self.production_line_id.id, + 'machine_tool_name_id': self.maintenance_equipment_id.id, + 'applicant': self.applicant, + 'apply_time': fields.Datetime.now(), + 'cutter_spacing_code_id': self.cutter_spacing_code_id.id, + 'whether_standard_knife': self.whether_standard_knife, + 'reason_for_applying': self.reason_for_applying, + 'sf_machine_table_tool_changing_apply_id': record.id + }) + # 修改机床换刀申请状态 + record.write({ + 'status': '1', + 'sf_functional_tool_assembly_id': sf_functional_tool_assembly.id + }) # 关闭弹出窗口 return {'type': 'ir.actions.act_window_close'} @@ -323,14 +337,14 @@ class FunctionalToolAssemblyOrder(models.TransientModel): string='组装后功能刀具类型') after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)') after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)') - after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧') + after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', default='0') cut_time = fields.Integer(string='已切削时间(min)') cut_length = fields.Float(string='已切削长度(mm)') cut_number = fields.Integer(string='已切削次数') after_assembly_whether_standard_knife = fields.Boolean(string='组装后是否标准刀', default=True) after_assembly_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], - string='组装后粗/中/精') + string='组装后粗/中/精', default='3') after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)') after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)') after_assembly_used_value = fields.Integer(string='组装后已使用值(min)')