Merge pull request #40263 from nabinhait/pi-optimization
perf: Performance optmization for Purchase Invoice submission
diff --git a/erpnext/stock/doctype/item_price/item_price.json b/erpnext/stock/doctype/item_price/item_price.json
index 707f346..bf944a4 100644
--- a/erpnext/stock/doctype/item_price/item_price.json
+++ b/erpnext/stock/doctype/item_price/item_price.json
@@ -104,7 +104,8 @@
"in_standard_filter": 1,
"label": "Price List",
"options": "Price List",
- "reqd": 1
+ "reqd": 1,
+ "search_index": 1
},
{
"bold": 1,
@@ -220,7 +221,7 @@
"idx": 1,
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2024-01-30 14:02:19.304854",
+ "modified": "2024-03-13 12:23:39.630290",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item Price",
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 1cb1057..3c8b808 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -103,22 +103,8 @@
if args.customer and cint(args.is_pos):
out.update(get_pos_profile_item_details(args.company, args, update_data=True))
- if (
- args.get("doctype") == "Material Request"
- and args.get("material_request_type") == "Material Transfer"
- ):
- out.update(get_bin_details(args.item_code, args.get("from_warehouse")))
-
- elif out.get("warehouse"):
- if doc and doc.get("doctype") == "Purchase Order":
- # calculate company_total_stock only for po
- bin_details = get_bin_details(
- args.item_code, out.warehouse, args.company, include_child_warehouses=True
- )
- else:
- bin_details = get_bin_details(args.item_code, out.warehouse, include_child_warehouses=True)
-
- out.update(bin_details)
+ if item.is_stock_item:
+ update_bin_details(args, out, doc)
# update args with out, if key or value not exists
for key, value in out.items():
@@ -169,6 +155,24 @@
out.update(get_valuation_rate(args.item_code, args.company, out.get("warehouse")))
+def update_bin_details(args, out, doc):
+ if (
+ args.get("doctype") == "Material Request"
+ and args.get("material_request_type") == "Material Transfer"
+ ):
+ out.update(get_bin_details(args.item_code, args.get("from_warehouse")))
+
+ elif out.get("warehouse"):
+ company = args.company if (doc and doc.get("doctype") == "Purchase Order") else None
+
+ # calculate company_total_stock only for po
+ bin_details = get_bin_details(
+ args.item_code, out.warehouse, company, include_child_warehouses=True
+ )
+
+ out.update(bin_details)
+
+
def process_args(args):
if isinstance(args, str):
args = json.loads(args)