fix: list the Purchase Orders created per supplier instead of opening one

Opening one of several created orders hid the rest and moved the buyer off the
Material Request. The created orders are now reported the way Production Plan
reports its documents, as links in a message, and the form stays put.

(cherry picked from commit 6f22551aae)
This commit is contained in:
Mihir Kandoi
2026-08-01 08:39:03 +05:30
committed by Mergify
parent d718110216
commit d2fe4b623c
2 changed files with 9 additions and 17 deletions

View File

@@ -7,7 +7,7 @@ import frappe
from frappe import _
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
from frappe.utils import cint, flt, getdate, nowdate
from frappe.utils import cint, comma_and, flt, get_link_to_form, getdate, nowdate
from erpnext.setup.doctype.brand.brand import get_brand_defaults
from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
@@ -242,6 +242,12 @@ def make_purchase_orders_by_supplier(source_name: str, item_suppliers: str | lis
purchase_order.insert()
purchase_orders.append(purchase_order.name)
frappe.msgprint(
_("{0} created").format(
comma_and([get_link_to_form("Purchase Order", name) for name in purchase_orders])
)
)
return purchase_orders

View File

@@ -534,23 +534,9 @@ frappe.ui.form.on("Material Request", {
args: { source_name: frm.doc.name, item_suppliers: item_suppliers },
freeze: true,
callback: function (r) {
if (r.exc) return;
dialog.hide();
const purchase_orders = r.message || [];
if (purchase_orders.length === 1) {
frappe.set_route("Form", "Purchase Order", purchase_orders[0]);
return;
if (!r.exc) {
dialog.hide();
}
frappe.msgprint({
title: __("Purchase Orders Created"),
indicator: "green",
message: purchase_orders
.map((name) => frappe.utils.get_form_link("Purchase Order", name, true))
.join(", "),
});
},
});
},