[Fix] Show a message while user tries to create Material request with BOM which contains only non-stock item
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 982534d..5efb8e4 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -56,7 +56,7 @@
if(doc.material_request_type === "Purchase")
cur_frm.add_custom_button(__("Supplier Quotation"),
this.make_supplier_quotation, __("Make"));
-
+
if(doc.material_request_type === "Manufacture" && doc.status === "Submitted")
cur_frm.add_custom_button(__("Production Order"),
this.raise_production_orders, __("Make"));
@@ -127,14 +127,18 @@
method: "erpnext.manufacturing.doctype.bom.bom.get_bom_items",
args: values,
callback: function(r) {
- $.each(r.message, function(i, item) {
- var d = frappe.model.add_child(cur_frm.doc, "Material Request Item", "items");
- d.item_code = item.item_code;
- d.description = item.description;
- d.warehouse = values.warehouse;
- d.uom = item.stock_uom;
- d.qty = item.qty;
- });
+ if(!r.message) {
+ frappe.throw(__("BOM does not contain any stock item"))
+ } else {
+ $.each(r.message, function(i, item) {
+ var d = frappe.model.add_child(cur_frm.doc, "Material Request Item", "items");
+ d.item_code = item.item_code;
+ d.description = item.description;
+ d.warehouse = values.warehouse;
+ d.uom = item.stock_uom;
+ d.qty = item.qty;
+ });
+ }
d.hide();
refresh_field("items");
}
@@ -162,7 +166,7 @@
run_link_triggers: true
});
},
-
+
make_request_for_quotation: function(){
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.material_request.material_request.make_request_for_quotation",