Skip to content

Commit

Permalink
perf: Duplicate queries for UOM (#35744)
Browse files Browse the repository at this point in the history
This query repeats for every item, UOMs rarely if ever change

(cherry picked from commit 29da1db)
  • Loading branch information
ankush authored and mergify[bot] committed Jun 16, 2023
1 parent 01ac54d commit 2219e4b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions erpnext/stock/doctype/pick_list/pick_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def before_save(self):
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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2219e4b

Please sign in to comment.