mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-17 08:28:44 +00:00
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.
This commit is contained in:
@@ -441,10 +441,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",
|
||||
@@ -504,6 +522,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,
|
||||
|
||||
Reference in New Issue
Block a user