mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-05 10:43:04 +00:00
feat: order only the items ticked in the supplier selection dialog
Every row is ticked when the dialog opens, so the common case of ordering
everything is unchanged, and a buyer who wants a partial order unticks what
should wait. Creating with nothing ticked is rejected.
(cherry picked from commit 07445b3675)
This commit is contained in:
@@ -207,6 +207,9 @@ def get_item_default_suppliers(source_name: str, filtered_children: str | list |
|
||||
def make_purchase_orders_by_supplier(source_name: str, item_suppliers: str | list) -> list[str]:
|
||||
"""Create one draft Purchase Order per supplier for the given Material Request items."""
|
||||
item_suppliers = frappe.parse_json(item_suppliers)
|
||||
if not item_suppliers:
|
||||
frappe.throw(_("Select at least one Item"))
|
||||
|
||||
pending_items = {
|
||||
d["material_request_item"]: frappe._dict(d) for d in get_item_default_suppliers(source_name)
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ 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 }));
|
||||
const rows = items.map((item) => Object.assign({}, item, { qty: item.pending_qty, __checked: 1 }));
|
||||
|
||||
const dialog = new frappe.ui.Dialog({
|
||||
title: __("Select Supplier for Items"),
|
||||
@@ -519,7 +519,10 @@ frappe.ui.form.on("Material Request", {
|
||||
],
|
||||
primary_action_label: __("Create"),
|
||||
primary_action: function (values) {
|
||||
const item_suppliers = values.items || [];
|
||||
const item_suppliers = (values.items || []).filter((row) => row.__checked);
|
||||
if (!item_suppliers.length) {
|
||||
frappe.throw(__("Select at least one Item"));
|
||||
}
|
||||
|
||||
const missing_supplier = item_suppliers.find((row) => !row.supplier);
|
||||
if (missing_supplier) {
|
||||
|
||||
Reference in New Issue
Block a user