From ba3578929eea16c83ea879381964f7374cab117a Mon Sep 17 00:00:00 2001 From: Andy Zhu Date: Tue, 27 Oct 2020 14:57:59 +1300 Subject: [PATCH] Update accounts_controller.py Updating Bin quantity based on doctype to optimize running efficiency. --- erpnext/controllers/accounts_controller.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index ba9f87f3a3..8d53914f6c 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1362,10 +1362,15 @@ def validate_and_delete_children(parent, data): d.delete() from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty, get_ordered_qty - update_bin_qty(d.item_code, d.warehouse, { - "reserved_qty": get_reserved_qty(d.item_code, d.warehouse), - "ordered_qty": get_ordered_qty(d.item_code, d.warehouse) - }) + # updating both will be time consuming, update it based on the doctype. reserved qty if sales order, otherwise ordered qty + if parent.doctype == "Sales Order": + update_bin_qty(d.item_code, d.warehouse, { + "reserved_qty": get_reserved_qty(d.item_code, d.warehouse) + }) + else: + update_bin_qty(d.item_code, d.warehouse, { + "ordered_qty": get_ordered_qty(d.item_code, d.warehouse) + }) @frappe.whitelist() def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, child_docname="items"):