From 4d04b375826e01491f4575049def299d4bc05a3d Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 7 Dec 2023 17:31:18 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=9C=BA=E5=8F=B0=E6=8D=A2=E5=88=80?= =?UTF-8?q?=E7=94=B3=E8=AF=B7tree=E8=A7=86=E5=9B=BE=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E6=9C=BA=E5=BA=8A=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=9C=BA=E5=8F=B0?= =?UTF-8?q?=E5=8F=B7=E5=AD=97=E6=AE=B5=E5=86=85=E5=AE=B9=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BD=8D=E6=9C=BA=E5=BA=8A=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=EF=BC=9B=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=87=BA=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E8=AE=B0=E5=BD=95=E6=A8=A1=E5=9E=8B=E6=9C=BA=E5=8F=B0?= =?UTF-8?q?=E5=8F=B7=E5=AD=97=E6=AE=B5=E5=86=85=E5=AE=B9=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BD=8D=E6=9C=BA=E5=BA=8A=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=EF=BC=9B2=E3=80=81=E8=A7=A3=E5=86=B3=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E6=9C=89=E7=9A=84=E5=87=BA=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=9C=BA=E5=BA=8A=E5=AD=97=E6=AE=B5=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=86=85=E5=AE=B9=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= =?UTF-8?q?3=E3=80=81=E6=96=B0=E5=A2=9E=E7=BB=A7=E6=89=BF=E6=9C=BA?= =?UTF-8?q?=E5=BA=8A=E5=88=80=E4=BD=8D=E6=A8=A1=E5=9E=8B=EF=BC=8C=E5=B0=86?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=9C=BA=E5=BA=8A=E5=88=80=E4=BD=8D=E6=97=B6?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=9C=BA=E5=8F=B0=E6=8D=A2=E5=88=80=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E8=AE=B0=E5=BD=95=E4=BB=8E=E5=8E=9F=E6=9C=BA=E5=BA=8A?= =?UTF-8?q?=E5=88=80=E4=BD=8D=E6=A8=A1=E5=9E=8B=E7=A7=BB=E5=8A=A8=E5=88=B0?= =?UTF-8?q?=E7=BB=A7=E6=89=BF=E5=90=8E=E7=9A=84=E6=9C=BA=E5=BA=8A=E5=88=80?= =?UTF-8?q?=E4=BD=8D=E6=A8=A1=E5=9E=8B=E4=B8=AD=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 10 ---------- sf_tool_management/models/__init__.py | 1 + sf_tool_management/models/base.py | 11 ++++------- .../models/maintenance_equipment.py | 15 +++++++++++++++ sf_tool_management/views/tool_base_views.xml | 2 +- sf_tool_management/wizard/wizard.py | 8 ++++---- 6 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 sf_tool_management/models/maintenance_equipment.py diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index bed75e6d..285d43f0 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -873,13 +873,3 @@ 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/__init__.py b/sf_tool_management/models/__init__.py index 3ab6007e..88279b79 100644 --- a/sf_tool_management/models/__init__.py +++ b/sf_tool_management/models/__init__.py @@ -1,2 +1,3 @@ from . import base from . import tool_material_search +from . import maintenance_equipment diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index fc58e6e0..cb057cb5 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -41,13 +41,10 @@ class FunctionalCuttingToolEntity(models.Model): def _compute_current_location_id(self): for record in self: if record.barcode_id.quant_ids: - print(record.barcode_id.quant_ids) for quant_id in record.barcode_id.quant_ids: if quant_id.inventory_quantity_auto_apply > 0: - print(quant_id) record.current_location_id = quant_id.location_id record.current_location = quant_id.location_id.name - print(record.current_location_id) if record.current_location_id: record.get_location_num() else: @@ -161,7 +158,7 @@ class FunctionalToolWarning(models.Model): production_line_id = fields.Many2one('sf.production.line', string='生产线', group_expand='_read_group_machine_table_name_ids') maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床') - machine_tool_code = fields.Char(string='机台号') + machine_tool_code = fields.Char(string='机台号', related='maintenance_equipment_id.name') machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型') cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', domain="[('equipment_id', '=', maintenance_equipment_id)]") @@ -222,7 +219,7 @@ class StockMoveLine(models.Model): related='functional_tool_name_id.functional_tool_type_id') diameter = fields.Integer(string='刀具直径(mm)', related='functional_tool_name_id.functional_tool_diameter') knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', related='functional_tool_name_id.knife_tip_r_angle') - install_tool_time = fields.Datetime("刀具组装时间") + install_tool_time = fields.Datetime("刀具组装时间", related='functional_tool_name_id.tool_loading_time') @api.model def _read_group_functional_tool_type_id(self, categories, domain, order): @@ -339,7 +336,7 @@ class MachineTableToolChangingApply(models.Model): 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) + machine_tool_code = fields.Char(string='机台号', related='maintenance_equipment_id.name') cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True, required=True, domain="[('equipment_id', '=', maintenance_equipment_id)]") # 功能刀具信息 @@ -355,7 +352,7 @@ class MachineTableToolChangingApply(models.Model): [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), ('直装固定式', '直装固定式')], string='刀位接口型号') - diameter = fields.Integer(string='刀具直径(mm)', ) + diameter = fields.Integer(string='刀具直径(mm)') knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') max_lifetime_value = fields.Integer(string='最大寿命值(min)') alarm_value = fields.Integer(string='报警值(min)') diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py new file mode 100644 index 00000000..f5371a3f --- /dev/null +++ b/sf_tool_management/models/maintenance_equipment.py @@ -0,0 +1,15 @@ +from odoo import models, api + + +class SfMaintenanceEquipmentTool(models.Model): + _inherit = 'maintenance.equipment.tool' + + @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/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 9d4e4a64..eb0cd379 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -478,7 +478,7 @@ - + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index d5445694..8b3af487 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -378,7 +378,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 创建功能刀具批次/序列号记录 stock_lot = product_id.create_assemble_warehouse_receipt(self.id, functional_tool_assembly) # 创建刀具组装入库单 - self.create_stocking_picking(stock_lot) + self.create_stocking_picking(stock_lot, functional_tool_assembly) # 刀具物料出库 if self.integral_code_id: product_id.tool_material_stock_moves(self.integral_code_id) @@ -436,7 +436,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): if not self.bar_code_id and not self.pad_code_id: raise ValidationError('【刀盘】和【刀杆】必须填写一个!') - def create_stocking_picking(self, stock_lot): + def create_stocking_picking(self, stock_lot, functional_tool_assembly): """ 创建刀具组装入库单 """ @@ -450,7 +450,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel): self.env['stock.move.line'].create({ 'picking_id': picking_id.id, 'product_id': stock_lot.product_id.id, - 'lot_id': stock_lot.id + 'lot_id': stock_lot.id, + 'functional_tool_name_id': functional_tool_assembly.id }) # 将刀具组装入库单的状态更改为就绪 picking_id.action_confirm() @@ -572,7 +573,6 @@ class ProductProduct(models.Model): """ # 获取位置对象 location_inventory_id = tool_material.quant_ids.location_id[-1] - print(location_inventory_id) stock_location_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')]) # 创建功能刀具该批次/序列号 库存移动和移动历史 tool_material.create_stock_quant(location_inventory_id, stock_location_id, None)