From a37608a36cad289770767f7b54d7289cd1ca7247 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 24 May 2023 15:24:05 +0530 Subject: [PATCH] fix: Negative value in Reserved Qty for Production Plan --- .../manufacturing/doctype/production_plan/production_plan.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index e40539acf3..0800bdd2af 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -1534,7 +1534,7 @@ def get_reserved_qty_for_production_plan(item_code, warehouse): frappe.qb.from_(table) .inner_join(child) .on(table.name == child.parent) - .select(Sum(child.quantity * IfNull(child.conversion_factor, 1.0))) + .select(Sum(child.required_bom_qty * IfNull(child.conversion_factor, 1.0))) .where( (table.docstatus == 1) & (child.item_code == item_code) @@ -1552,6 +1552,9 @@ def get_reserved_qty_for_production_plan(item_code, warehouse): get_reserved_qty_for_production(item_code, warehouse, check_production_plan=True) ) + if reserved_qty_for_production > reserved_qty_for_production_plan: + return 0.0 + return reserved_qty_for_production_plan - reserved_qty_for_production