fix: Handle `Get Items From` in Sales Order
- Map all non alternatives from Quotation to SO if no selected items
- Show disclaimer mentioning that Qtns with alternatives must be mapped to SO from the Qtn form
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 185f63c..b5eddce 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -303,16 +303,20 @@
def can_map_row(item) -> bool:
"""
Row mapping from Quotation to Sales order:
- 1. Simple row: Map if adequate qty
- 2. Has Alternative Item: Map if no alternative was selected against original item and #1
- 3. Is Alternative Item: Map if alternative was selected against original item and #1
+ 1. If no selections, map all non-alternative rows (that sum up to the grand total)
+ 2. If selections: Is Alternative Item/Has Alternative Item: Map if selected and adequate qty
+ 3. If selections: Simple row: Map if adequate qty
"""
has_qty = item.qty > 0
- if not (item.is_alternative or item.has_alternative_item):
- # No alternative items in doc or current row is a simple item (without alternatives)
- return has_qty
- return (item.name in selected_rows) and has_qty
+ if not selected_rows:
+ return not item.is_alternative
+
+ if selected_rows and (item.is_alternative or item.has_alternative_item):
+ return (item.name in selected_rows) and has_qty
+
+ # Simple row
+ return has_qty
doclist = get_mapped_doc(
"Quotation",
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index fb64772..a0a63f6 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -275,7 +275,7 @@
if (this.frm.doc.docstatus===0) {
this.frm.add_custom_button(__('Quotation'),
function() {
- erpnext.utils.map_current_doc({
+ let d = erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.quotation.quotation.make_sales_order",
source_doctype: "Quotation",
target: me.frm,
@@ -293,7 +293,16 @@
docstatus: 1,
status: ["!=", "Lost"]
}
- })
+ });
+
+ setTimeout(() => {
+ d.$parent.append(`
+ <span class='small text-muted'>
+ ${__("Note: Please create Sales Orders from individual Quotations to select from among Alternative Items.")}
+ </span>
+ `);
+ }, 200);
+
}, __("Get Items From"));
}