fix: reject the same Material Request item twice in one supplier selection

Each row was checked against the pending quantity on its own, so a payload that
listed one item under two suppliers passed both checks and ordered the pending
quantity twice. The dialog cannot produce that, a direct call to the endpoint
can.

(cherry picked from commit 99d56cc850)
This commit is contained in:
Mihir Kandoi
2026-08-01 09:11:37 +05:30
committed by Mergify
parent 06a753faf3
commit ea770f6a8e

View File

@@ -215,11 +215,17 @@ def make_purchase_orders_by_supplier(source_name: str, item_suppliers: str | lis
}
items_by_supplier = {}
requested_items = set()
for row in item_suppliers:
row = frappe._dict(row)
pending = pending_items.get(row.material_request_item) or frappe._dict()
item_link = get_link_to_form("Item", row.item_code)
if row.material_request_item in requested_items:
frappe.throw(_("Item {0} cannot be ordered more than once").format(item_link))
requested_items.add(row.material_request_item)
if not row.supplier:
frappe.throw(_("Select a Supplier for Item {0}").format(item_link))