From d1811ea24ba4af1d43ee1fea88ad7bab819d98d6 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Tue, 17 Jun 2025 16:33:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E9=BD=90=E5=A5=97=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_demand_plan/models/sf_production_demand_plan.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index c0121d58..b1cbf13d 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -278,9 +278,15 @@ class SfProductionDemandPlan(models.Model): if record.sale_order_id and record.sale_order_id.mrp_production_ids: manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered( lambda mo: mo.product_id == record.product_id) + if manufacturing_orders and manufacturing_orders.move_raw_ids: + # 获取完成的制造订单 + done_manufacturing = manufacturing_orders.filtered(lambda mo: mo.state == 'done') + product_qty = sum(done_manufacturing.mapped('product_qty')) + # 需求数量-完成数量 + product_uom_qty = record.product_uom_qty - product_qty total_reserved_availability = sum(manufacturing_orders.mapped('move_raw_ids.reserved_availability')) - if float_compare(total_reserved_availability, record.product_uom_qty, + if float_compare(total_reserved_availability, product_uom_qty, precision_rounding=record.product_id.uom_id.rounding) >= 0: record.material_check = '1' # 已齐套 else: