From f2da553437eb970023d05aa69e783414d2be64de Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 7 Feb 2024 19:26:14 +0530 Subject: [PATCH] fix: incorrect planned qty in PP (backport #39785) (#39792) fix: incorrect planned qty in PP (cherry picked from commit a8ebc94a366e8f15e9bbeab3da064cf5f22dd1b9) Co-authored-by: s-aga-r (cherry picked from commit df9d52d3ce7155fb7f917383c7d795769aed1c15) --- .../doctype/production_plan/production_plan.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index c98d639663ac..6ccd11bf9ff0 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -236,9 +236,10 @@ def get_so_items(self): so_item.parent, so_item.item_code, so_item.warehouse, - ( - (so_item.qty - so_item.work_order_qty - so_item.delivered_qty) * so_item.conversion_factor - ).as_("pending_qty"), + so_item.qty, + so_item.work_order_qty, + so_item.delivered_qty, + so_item.conversion_factor, so_item.description, so_item.name, so_item.bom_no, @@ -261,6 +262,11 @@ def get_so_items(self): items = items_query.run(as_dict=True) + for item in items: + item.pending_qty = ( + flt(item.qty) - max(item.work_order_qty, item.delivered_qty, 0) * item.conversion_factor + ) + pi = frappe.qb.DocType("Packed Item") packed_items_query = (