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)