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:
diff --git a/sf_demand_plan/views/demand_plan.xml b/sf_demand_plan/views/demand_plan.xml
index f78e5cf6..c0b1e5a9 100644
--- a/sf_demand_plan/views/demand_plan.xml
+++ b/sf_demand_plan/views/demand_plan.xml
@@ -3,7 +3,7 @@
sf.production.demand.plan.tree
sf.production.demand.plan
-