hotfix in patch
diff --git a/erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py b/erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py
index 0e7796a..169b1e2 100644
--- a/erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py
+++ b/erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py
@@ -8,6 +8,7 @@
 	cancelled_invoices = frappe.db.sql_list("""select name from `tabSales Invoice` 
 		where docstatus = 2 and ifnull(update_stock, 0) = 1""")
 
-	frappe.db.sql("""delete from `tabGL Entry` 
-		where voucher_type = 'Sales Invoice' and voucher_no in (%s)""" 
-		% (', '.join(['%s']*len(cancelled_invoices))), tuple(cancelled_invoices))
\ No newline at end of file
+	if cancelled_invoices:
+		frappe.db.sql("""delete from `tabGL Entry` 
+			where voucher_type = 'Sales Invoice' and voucher_no in (%s)""" 
+			% (', '.join(['%s']*len(cancelled_invoices))), tuple(cancelled_invoices))
\ No newline at end of file