From c6b1c5e0472750aba5a9e2a1f7ca3edf2a616b96 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Wed, 17 Apr 2024 14:55:45 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E5=88=97=E8=A1=A8=E6=A8=A1=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0=E8=AE=A1=E7=AE=97=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E6=94=B9=E4=B8=BA=E5=88=9B=E5=BB=BA=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=B6=E7=BB=99=E6=95=B0=E6=8D=AE=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85?= =?UTF-8?q?=E5=8D=95=E5=BC=B9=E7=AA=97=E6=B7=BB=E5=8A=A0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E6=97=A7=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=96=B0=E5=88=80=E5=85=B7=E7=9A=84=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=EF=BC=9B=E4=BC=98=E5=8C=96=E6=B2=A1=E6=9C=89=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8F=B7=E7=9A=84=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99?= =?UTF-8?q?=E7=9A=84=E5=BA=93=E5=AD=98=E4=BD=8D=E7=A7=BB=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=9C=A8=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99?= =?UTF-8?q?=E5=87=BA=E5=BA=93=E5=90=8C=E6=97=B6=E8=B4=A7=E4=BD=8D=E7=89=A9?= =?UTF-8?q?=E6=96=99=E6=95=B0=E5=87=8F=E4=B8=80=EF=BC=9B=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E5=88=9B=E5=BB=BA=E5=88=80=E5=85=B7=E7=BB=84?= =?UTF-8?q?=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/functional_tool.py | 22 ++----------- .../views/functional_tool_views.xml | 7 +++-- sf_tool_management/wizard/wizard.py | 31 +++++++++++++------ sf_tool_management/wizard/wizard_view.xml | 8 +++-- 4 files changed, 34 insertions(+), 34 deletions(-) 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 @@ - + - +