Merge pull request #11510 from rohitwaghchaure/issue_11502

Add item directly in the cart only if serial no, batch, barcode has enter in the search field
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js
index a0f8598..adde913 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.js
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.js
@@ -990,18 +990,18 @@
 		}
 
 		this.get_items({search_value: search_term, item_group })
-			.then(({ items, serial_no, batch_no }) => {
+			.then(({ items, serial_no, batch_no, barcode }) => {
 				if (search_term) {
 					this.search_index[search_term] = items;
 				}
 
 				this.items = items;
 				this.render_items(items);
-				this.set_item_in_the_cart(items, serial_no, batch_no);
+				this.set_item_in_the_cart(items, serial_no, batch_no, barcode);
 			});
 	}
 
-	set_item_in_the_cart(items, serial_no, batch_no) {
+	set_item_in_the_cart(items, serial_no, batch_no, barcode) {
 		if (serial_no) {
 			this.events.update_cart(items[0].item_code,
 				'serial_no', serial_no);
@@ -1016,7 +1016,7 @@
 			return;
 		}
 
-		if (items.length === 1) {
+		if (items.length === 1 && (serial_no || batch_no || barcode)) {
 			this.events.update_cart(items[0].item_code,
 				'qty', '+1');
 			this.reset_search_field();
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py
index 20b5bb0..8dad0a3 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.py
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.py
@@ -67,6 +67,11 @@
 			'batch_no': batch_no
 		})
 
+	if barcode:
+		res.update({
+			'barcode': barcode
+		})
+
 	return res
 
 def get_conditions(item_code, serial_no, batch_no, barcode):