From ea3d9e5375c70d6c13bee2913d9559fab9eea4e6 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Wed, 14 May 2025 16:46:29 +0800 Subject: [PATCH] =?UTF-8?q?sf-=E5=88=B6=E9=80=A0-=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E5=A4=96=E5=8D=8F=E7=9A=84=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E5=90=8E=EF=BC=8C=E5=A4=96=E5=8D=8F=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E6=8B=A8=E5=8D=95=E7=9A=84=E4=BD=9C=E4=B8=9A=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E7=9A=84=E9=A2=84=E7=95=99=E6=95=B0=E9=87=8F=E8=B7=9F?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=95=B0=E9=87=8F=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index e35e33cc..19323c21 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1283,13 +1283,12 @@ class ResMrpWorkOrder(models.Model): workorder.state = 'waiting' continue purchase_orders_id = self._get_surface_technics_purchase_ids() - location_id = self.env['stock.location'].search([('name', '=', '制造前')]) - quants = self.env['stock.quant'].search([ - ('product_id', '=', workorder.production_id.bom_id.bom_line_ids.product_id.id), - ('location_id', '=', location_id.id) - ]) - total_qty = sum(quants.mapped('quantity')) # 计算该位置的总库存量 - if purchase_orders_id.state == 'purchase' and total_qty >= workorder.production_id.product_qty: + purchase_count = 0 + for purchase_order in purchase_orders_id: + for purchase_order_line in purchase_order.order_line: + if purchase_order_line.product_id.server_product_process_parameters_id.id == workorder.surface_technics_parameters_id.id: + purchase_count = purchase_order_line.product_qty + if purchase_orders_id.state == 'purchase' and purchase_count>=workorder.production_id.product_qty: workorder.state = 'ready' picking_id = workorder.production_id.picking_ids.filtered( lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')