diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index 478fb744..c37d5317 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -11,27 +11,11 @@ class FunctionalCuttingToolEntity(models.Model): _description = '功能刀具列表' functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具组装单', readonly=True) - - @api.depends('functional_tool_name_id') - def _compute_name(self): - for item in self: - if item.functional_tool_name_id: - name = item.functional_tool_name_id.after_assembly_functional_tool_name - inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', name)]) - item.name = name - if inventory: - item.tool_name_id = inventory.id - else: - item.tool_name_id = False - else: - item.name = '' - item.tool_name_id = False - tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id') code = fields.Char('编码') rfid = fields.Char('Rfid', readonly=True) - name = fields.Char('名称', compute='_compute_name', stroe=True) - tool_name_id = fields.Many2one('sf.tool.inventory', '功能刀具名称', compute='_compute_name', store=True) + name = fields.Char('名称') + tool_name_id = fields.Many2one('sf.tool.inventory', '功能刀具名称') sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号') barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', @@ -302,7 +286,7 @@ class StockMoveLine(models.Model): _description = '功能刀具出入库记录' _order = 'date desc' - functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称') + functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具组装单') functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, group_expand='_read_group_functional_tool_type_id') functional_tool_name = fields.Char('刀具名称') diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml index d8907859..82fbd8bc 100644 --- a/sf_tool_management/views/functional_tool_views.xml +++ b/sf_tool_management/views/functional_tool_views.xml @@ -397,7 +397,7 @@ - + @@ -458,7 +458,8 @@ - + + @@ -481,7 +482,7 @@ - + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index b6f963f6..979d8efe 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -221,6 +221,14 @@ class FunctionalToolAssemblyOrder(models.TransientModel): image = fields.Binary('图片') + @api.onchange('functional_tool_name') + def _onchange_functional_tool_name(self): + for item in self: + if item.functional_tool_name: + inventory = self.env['sf.tool.inventory'].sudo().search([('name', '=', item.functional_tool_name)]) + if inventory: + item.after_name_id = inventory.id + # 功能刀具组装信息 # ===============整体式刀具型号================= integral_freight_barcode = fields.Char('整体式刀具货位') @@ -461,7 +469,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): obj.tool_code = str_2 def _get_code(self, str_2): - functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().search( + functional_tool_assembly = self.env['sf.functional.cutting.tool.entity'].sudo().search( [('code', 'like', str_2)], limit=1, order="id desc" @@ -548,15 +556,15 @@ class FunctionalToolAssemblyOrder(models.TransientModel): if self.handle_code_id: product_id.tool_material_stock_moves(self.handle_code_id) if self.integral_product_id: - self.integral_product_id.material_stock_moves() + self.integral_product_id.material_stock_moves(self.integral_freight_barcode) if self.blade_product_id: - self.blade_product_id.material_stock_moves() + self.blade_product_id.material_stock_moves(self.blade_freight_barcode) if self.bar_product_id: - self.bar_product_id.material_stock_moves() + self.bar_product_id.material_stock_moves(self.bar_freight_barcode) if self.pad_product_id: - self.pad_product_id.material_stock_moves() + self.pad_product_id.material_stock_moves(self.pad_freight_barcode) if self.chuck_product_id: - self.chuck_product_id.material_stock_moves() + self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode) # ============================创建功能刀具列表、安全库存记录=============================== # 封装功能刀具数据 @@ -643,7 +651,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel): return { 'barcode_id': stock_lot.id, 'code': self.tool_code, - 'name': self.after_assembly_functional_tool_name, + 'name': self.after_name_id.name, + 'tool_name_id': self.after_name_id.id, 'rfid': self.rfid, 'tool_groups_id': self.after_tool_groups_id.id, 'functional_tool_name_id': functional_tool_assembly_id.id, @@ -784,7 +793,7 @@ class ProductProduct(models.Model): # 创建功能刀具该批次/序列号 库存移动和移动历史 tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装', False) - def material_stock_moves(self): + def material_stock_moves(self, shelf_location_barcode): # 创建库存移动记录 stock_move_id = self.env['stock.move'].sudo().create({ 'name': '功能刀具组装', @@ -795,15 +804,19 @@ class ProductProduct(models.Model): 'state': 'done' }) + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)]) # 创建移动历史记录 stock_move_line_id = self.env['stock.move.line'].sudo().create({ 'product_id': self.id, - 'lot_id': self.id, 'move_id': stock_move_id.id, + 'current_location_id': location.id, 'install_tool_time': fields.Datetime.now(), 'qty_done': 1.0, 'state': 'done', }) + + location.product_num = location.product_num - 1 + return stock_move_id, stock_move_line_id diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml index 386c8d7c..0eb2a77f 100644 --- a/sf_tool_management/wizard/wizard_view.xml +++ b/sf_tool_management/wizard/wizard_view.xml @@ -288,7 +288,7 @@ + attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False)]}">
@@ -336,11 +336,13 @@ - + - +