diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index 3aa85ceb..7977ed80 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -329,7 +329,7 @@ class ToolInventory(models.Model): blade_number = fields.Integer('刃数(个)') extension = fields.Float('伸出长度(mm)') work_material = fields.Selection([('钢', '钢'), ('铝', '铝')], string='加工材料') - life_span = fields.Float('寿命(h)') + life_span = fields.Float('寿命(min)') tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组') diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 4f4f35a5..a83065bd 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -425,6 +425,18 @@ class ProductionLot(models.Model): # 'target': 'self', # } + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if vals.get('rfid'): + lots = self.env['stock.lot'].search([('rfid', '=', vals['rfid'])]) + if lots: + for lot in lots: + raise ValidationError('Rfid【%s】已被序列号为【%s】的【%s】产品占用!' % ( + lot.rfid, lot.name, lot.product_id.name)) + records = super(ProductionLot, self).create(vals_list) + return records + class StockPicking(models.Model): _inherit = 'stock.picking' diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml index 53e050d9..abad7539 100644 --- a/sf_tool_management/views/functional_tool_views.xml +++ b/sf_tool_management/views/functional_tool_views.xml @@ -184,27 +184,10 @@ sf.functional.cutting.tool.entity - - - + - - - - - - - - - - - - - - - diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index d6981922..c867d708 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -615,17 +615,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel): self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly, self) # 刀具物料出库 if self.handle_code_id: - product_id.tool_material_stock_moves(self.handle_code_id) + product_id.tool_material_stock_moves(self.handle_code_id, self.assembly_order_code) if self.integral_product_id: - self.integral_product_id.material_stock_moves(self.integral_freight_barcode) + self.integral_product_id.material_stock_moves(self.integral_freight_barcode,self.assembly_order_code) if self.blade_product_id: - self.blade_product_id.material_stock_moves(self.blade_freight_barcode) + self.blade_product_id.material_stock_moves(self.blade_freight_barcode,self.assembly_order_code) if self.bar_product_id: - self.bar_product_id.material_stock_moves(self.bar_freight_barcode) + self.bar_product_id.material_stock_moves(self.bar_freight_barcode,self.assembly_order_code) if self.pad_product_id: - self.pad_product_id.material_stock_moves(self.pad_freight_barcode) + self.pad_product_id.material_stock_moves(self.pad_freight_barcode,self.assembly_order_code) if self.chuck_product_id: - self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode) + self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode,self.assembly_order_code) # ============================创建功能刀具列表、安全库存记录=============================== # 封装功能刀具数据 @@ -820,7 +820,7 @@ class ProductProduct(models.Model): stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')]) # 创建功能刀具该批次/序列号 库存移动和移动历史 stock_lot.create_stock_quant(location_inventory_id, stock_location_id, functional_tool_assembly.id, - '功能刀具组装', obj, obj.after_tool_groups_id) + self.assembly_order_code, obj, obj.after_tool_groups_id) return stock_lot @@ -846,7 +846,7 @@ class ProductProduct(models.Model): num = "%03d" % m return code + str(num) - def tool_material_stock_moves(self, tool_material): + def tool_material_stock_moves(self, tool_material, assembly_order_code): """ 对刀具物料进行库存移动到 刀具组装位置 """ @@ -854,12 +854,12 @@ class ProductProduct(models.Model): location_inventory_id = tool_material.quant_ids.location_id[-1] stock_location_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')]) # 创建功能刀具该批次/序列号 库存移动和移动历史 - tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装', False, False) + tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, assembly_order_code, False, False) - def material_stock_moves(self, shelf_location_barcode): + def material_stock_moves(self, shelf_location_barcode, assembly_order_code): # 创建库存移动记录 stock_move_id = self.env['stock.move'].sudo().create({ - 'name': '功能刀具组装', + 'name': assembly_order_code, 'product_id': self.id, 'location_id': self.env['stock.location'].search([('name', '=', '刀具房')]).id, 'location_dest_id': self.env['stock.location'].search([('name', '=', '刀具组装位置')]).id,