mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-07 23:31:20 +00:00
refactor(purchase-order): use ORM syntax for min order quantity query (#54778)
* refactor(purchase-order): use ORM syntax for min order quantity query Use frappe.get_all instead of raw SQL with manual string formatting to fetch min_order_qty. This improves code readability and leverages the framework's built-in database abstraction. * chore: fix formatting * chore: fix formatting * chore: fix formatting by adding a space
This commit is contained in:
@@ -293,15 +293,14 @@ class PurchaseOrder(BuyingController):
|
||||
self.party_account_currency = get_party_account_currency("Supplier", self.supplier, self.company)
|
||||
|
||||
def validate_minimum_order_qty(self):
|
||||
"""Check if total ordered quantities meet the Item's minimum order requirement."""
|
||||
if not self.get("items"):
|
||||
return
|
||||
items = list(set(d.item_code for d in self.get("items")))
|
||||
|
||||
itemwise_min_order_qty = frappe._dict(
|
||||
frappe.db.sql(
|
||||
"""select name, min_order_qty
|
||||
from tabItem where name in ({})""".format(", ".join(["%s"] * len(items))),
|
||||
items,
|
||||
frappe.get_all(
|
||||
"Item", fields=["name", "min_order_qty"], filters={"name": ["in", items]}, as_list=True
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user