From 17fdf20e0371510efd13297bfe44f3e3a3b1aa0b Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 14 Apr 2025 10:30:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=BB=84=E8=A3=85=E8=87=AA=E5=8A=A8=E6=A0=B9=E6=8D=AEBOM?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=88=9D=E5=A7=8B=E7=89=A9=E6=96=99=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 72be50dd..2fa805b1 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -782,7 +782,8 @@ class FunctionalToolAssembly(models.Model): """根据BOM对刀具物料进行初始配置""" options = bom.get('options') # 配置刀柄信息 - for handle_id in bom.get('handle_ids'): + handle_ids = self._get_old_tool_material_lot(bom.get('handle_ids')) + for handle_id in handle_ids: if handle_id: if not self.handle_product_id: self.handle_product_id = handle_id.id @@ -820,19 +821,20 @@ class FunctionalToolAssembly(models.Model): location_id = self.env['stock.location'].search([('name', '=', '刀具房')]) stock_quant = self.env['stock.quant'].sudo().search( [('location_id', '=', location_id.id), ('product_id', 'in', material_ids.ids), ('quantity', '>', '0')], - order='lot_id', limit=1) + order='lot_id') if stock_quant: - return stock_quant.lot_id + return [quant.lot_id for quant in stock_quant] else: raise ValidationError(f'【{material_ids[0].cutting_tool_material_id.name}】物料库存不足,请先进行盘点或采购') - def _get_shelf_location_lot(self, lot_id): + def _get_shelf_location_lot(self, lot_ids): """根据所给的刀具物料批次号,返回一个刀具物料货位、批次信息""" - location_lots = self.env['sf.shelf.location.lot'].sudo().search([('lot_id', '=', lot_id.id)]) - if not location_lots: - raise ValidationError(f'没有查询到批次为【{lot_id.name}】物料的货位信息!') - else: - return location_lots[0] + for lot_id in lot_ids: + location_lots = self.env['sf.shelf.location.lot'].sudo().search([('lot_id', '=', lot_id.id)]) + if location_lots: + return location_lots[0] + raise ValidationError(f'【{lot_ids[0].product_id.cutting_tool_material_id.name}】物料在货位库存不足,请先进行盘点入库') + def _get_inventory_bom(self, inventory_id): """获取BOM的刀具物料产品信息""" From 37edc858c2d39739385fc3f43e1b832599f514c9 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 14 Apr 2025 10:32:26 +0800 Subject: [PATCH 2/2] 1 --- sf_tool_management/models/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 2fa805b1..3d9ec5ee 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -786,7 +786,7 @@ class FunctionalToolAssembly(models.Model): for handle_id in handle_ids: if handle_id: if not self.handle_product_id: - self.handle_product_id = handle_id.id + self.handle_product_id = handle_id.product_id.id break # 刀柄之外的物料配置