From 93331a1cf01e2407c6c943258221398d6f31a503 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sat, 1 Aug 2026 09:16:13 +0530 Subject: [PATCH] fix: warn about existing draft orders before the supplier selection creates more Creating through the dialog calls the endpoint directly instead of going through open_mapped_doc, so the draft link guard that every other Create action runs never fired, and a repeated dialog quietly produced a second set of draft orders for the same quantity. (cherry picked from commit f0bb70539db2c484c543ccb614a0a45b11b7dfe6) --- erpnext/stock/doctype/material_request/material_request.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index 787ea536811..4835f9d30d6 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -518,7 +518,7 @@ frappe.ui.form.on("Material Request", { }, ], primary_action_label: __("Create"), - primary_action: function (values) { + primary_action: async function (values) { const item_suppliers = (values.items || []).filter((row) => row.__checked); if (!item_suppliers.length) { frappe.throw(__("Select at least one Item")); @@ -552,6 +552,10 @@ frappe.ui.form.on("Material Request", { ); } + if (!(await erpnext.utils.confirm_if_drafts_exist(frm.doc, "Purchase Order"))) { + return; + } + frappe.call({ method: "erpnext.stock.doctype.material_request.mapper.make_purchase_orders_by_supplier", args: { source_name: frm.doc.name, item_suppliers: item_suppliers },