Merge branch 'master' into hotfix
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index d69a306..e362db0 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -426,11 +426,16 @@
 		});
 
 		this.serach_item.make_input();
-		this.serach_item.$input.on("keyup", function () {
-			setTimeout(function () {
-				me.items = me.get_items();
-				me.make_item_list();
-			}, 1000);
+		
+		this.serach_item.$input.on("keypress", function (event) {
+
+			clearTimeout(me.last_search_timeout);
+			me.last_search_timeout = setTimeout(() => {
+				if((me.serach_item.$input.val() != "") || (event.which == 13)) {
+					me.items = me.get_items();
+					me.make_item_list();
+				}				
+			}, 400);
 		});
 
 		this.search_item_group = this.wrapper.find('.search-item-group');
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index eaf064b..a333ca8 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -125,7 +125,33 @@
 				}
 			});
 		}
-	}
+	},
+
+	/**
+	* Checks if the first row of a given child table is empty
+	* @param child_table - Child table Doctype
+	* @return {Boolean}
+	**/
+	first_row_is_empty: function(child_table){
+		if($.isArray(child_table) && child_table.length > 0) {
+			return !child_table[0].item_code;
+		}
+		return false;
+	},
+
+	/**
+	* Removes the first row of a child table if it is empty
+	* @param {_Frm} frm - The current form
+	* @param {String} child_table_name - The child table field name
+	* @return {Boolean}
+	**/
+	remove_empty_first_row: function(frm, child_table_name){
+		const rows = frm['doc'][child_table_name];
+		if (this.first_row_is_empty(rows)){
+			frm['doc'][child_table_name] = rows.splice(1);
+		}
+		return rows;
+	},
 });
 
 erpnext.utils.map_current_doc = function(opts) {
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index fc0b9b2..7043fb7 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -153,9 +153,11 @@
 					if(!r.message) {
 						frappe.throw(__("BOM does not contain any stock item"))
 					} else {
+						erpnext.utils.remove_empty_first_row(cur_frm, "items");
 						$.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.item_name = item.item_name;
 							d.description = item.description;
 							d.warehouse = values.warehouse;
 							d.uom = item.stock_uom;
diff --git a/erpnext/stock/doctype/material_request/tests/test_material_request_from_bom.js b/erpnext/stock/doctype/material_request/tests/test_material_request_from_bom.js
new file mode 100644
index 0000000..d8b39fe
--- /dev/null
+++ b/erpnext/stock/doctype/material_request/tests/test_material_request_from_bom.js
@@ -0,0 +1,28 @@
+QUnit.module('manufacturing');
+
+QUnit.test("test material request get items from BOM", function(assert) {
+	assert.expect(4);
+	let done = assert.async();
+	frappe.run_serially([
+		() => frappe.set_route('Form', 'BOM'),
+		() => frappe.timeout(3),
+		() => frappe.click_button('Get Items from BOM'),
+		() => frappe.timeout(3),
+		() => {
+			assert.ok(cur_dialog, 'dialog appeared');
+		},
+		() => cur_dialog.set_value('bom', 'Laptop'),
+		() => cur_dialog.set_value('warehouse', 'Laptop Scrap Warehouse'),
+		() => frappe.click_button('Get Items from BOM'),
+		() => frappe.timeout(3),
+		() => {
+			assert.ok(cur_frm.doc.items[0].item_code, "First row is not empty");
+			assert.ok(cur_frm.doc.items[0].item_name, "Item name is not empty");
+			assert.equal(cur_frm.doc.items[0].item_name, "Laptop", cur_frm.doc.items[0].item_name);
+		},
+		() => cur_frm.doc.items[0].schedule_date = '2017-12-12',
+		() => cur_frm.save(),
+		() => done()
+	]);
+});
+