From 9b647bed5c77d9ef2d2aff8a8cb589498fe9845b Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sat, 1 Aug 2026 09:19:49 +0530 Subject: [PATCH] feat: set one supplier across every item in the supplier selection dialog A Material Request where few items carry a default supplier meant picking the same supplier row by row. A Supplier field above the table copies its value into every row, leaving the exceptions to be corrected by hand. Both pickers skip suppliers that are disabled or barred from Purchase Orders by their scorecard standing. (cherry picked from commit e84bf44e5197a9004bc758786ae13be54c759cca) --- .../material_request/material_request.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index 4835f9d30d6..998c3d48477 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -447,10 +447,28 @@ frappe.ui.form.on("Material Request", { select_suppliers_for_items: function (frm, items) { const rows = items.map((item) => Object.assign({}, item, { qty: item.pending_qty, __checked: 1 })); + const supplier_query = () => { + return { filters: { disabled: 0, prevent_pos: 0 } }; + }; + const dialog = new frappe.ui.Dialog({ title: __("Select Supplier for Items"), size: "large", fields: [ + { + fieldname: "supplier", + fieldtype: "Link", + options: "Supplier", + label: __("Set Supplier for All Items"), + get_query: supplier_query, + onchange: function () { + const supplier = dialog.get_value("supplier"); + if (!supplier) return; + + rows.forEach((row) => (row.supplier = supplier)); + dialog.fields_dict.items.grid.refresh(); + }, + }, { fieldname: "items", fieldtype: "Table", @@ -510,6 +528,7 @@ frappe.ui.form.on("Material Request", { fieldname: "supplier", options: "Supplier", label: __("Supplier"), + get_query: supplier_query, reqd: 1, in_list_view: 1, columns: 3,