fix: travis issue
diff --git a/erpnext/stock/deprecated_serial_batch.py b/erpnext/stock/deprecated_serial_batch.py
index 8b4279b..b7c5d57 100644
--- a/erpnext/stock/deprecated_serial_batch.py
+++ b/erpnext/stock/deprecated_serial_batch.py
@@ -76,7 +76,6 @@
 
 	@deprecated
 	def get_sle_for_batches(self):
-		batch_nos = list(self.batch_nos.keys())
 		sle = frappe.qb.DocType("Stock Ledger Entry")
 
 		timestamp_condition = CombineDatetime(sle.posting_date, sle.posting_time) < CombineDatetime(
@@ -88,7 +87,11 @@
 				== CombineDatetime(self.sle.posting_date, self.sle.posting_time)
 			) & (sle.creation < self.sle.creation)
 
-		return (
+		batch_nos = self.batch_nos
+		if isinstance(self.batch_nos, dict):
+			batch_nos = list(self.batch_nos.keys())
+
+		query = (
 			frappe.qb.from_(sle)
 			.select(
 				sle.batch_no,
@@ -97,11 +100,15 @@
 			)
 			.where(
 				(sle.item_code == self.sle.item_code)
-				& (sle.name != self.sle.name)
 				& (sle.warehouse == self.sle.warehouse)
 				& (sle.batch_no.isin(batch_nos))
 				& (sle.is_cancelled == 0)
 			)
 			.where(timestamp_condition)
 			.groupby(sle.batch_no)
-		).run(as_dict=True)
+		)
+
+		if self.sle.name:
+			query = query.where(sle.name != self.sle.name)
+
+		return query.run(as_dict=True)