From 632b67cbc84fc4f478fc4a4e4b363134dcc7b500 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 16 Jun 2023 16:40:40 +0530 Subject: [PATCH] perf: Duplicate queries for UOM (backport #35744) (#35745) perf: Duplicate queries for UOM (#35744) This query repeats for every item, UOMs rarely if ever change (cherry picked from commit 29da1db516b3e07c236b47a60b11de00c8ed9349) Co-authored-by: Ankush Menat --- 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 0e440a1f586..99246774aa1 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -36,7 +36,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) @@ -474,7 +474,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