From 29da1db516b3e07c236b47a60b11de00c8ed9349 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 16 Jun 2023 16:38:30 +0530 Subject: [PATCH] perf: Duplicate queries for UOM (#35744) This query repeats for every item, UOMs rarely if ever change --- erpnext/stock/doctype/pick_list/pick_list.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py index 2ed9209fdd0..922f76cff2e 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -40,7 +40,7 @@ class PickList(Document): for location in self.get("locations"): if ( location.sales_order - and frappe.db.get_value("Sales Order", location.sales_order, "per_picked") == 100 + and frappe.db.get_value("Sales Order", location.sales_order, "per_picked", cache=True) == 100 ): frappe.throw( _("Row #{}: item {} has been picked already.").format(location.idx, location.item_code) @@ -498,7 +498,7 @@ def get_items_with_location_and_quantity(item_doc, item_location_map, docstatus) ) qty = stock_qty / (item_doc.conversion_factor or 1) - uom_must_be_whole_number = frappe.db.get_value("UOM", item_doc.uom, "must_be_whole_number") + uom_must_be_whole_number = frappe.get_cached_value("UOM", item_doc.uom, "must_be_whole_number") if uom_must_be_whole_number: qty = floor(qty) stock_qty = qty * item_doc.conversion_factor