Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py
index 6829f9f..7ba83aa 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/accounts/doctype/journal_voucher/journal_voucher.py
@@ -385,7 +385,7 @@
 		get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist, cancel=1)
 
 	def check_tds_payment_voucher(self):
-		tdsp =	sql("select parent from `tabTDS Payment Detail` where voucher_no = '%s' and docstatus = 1 and parent not like 'old%'")
+		tdsp =	sql("select parent from `tabTDS Payment Detail` where voucher_no = %s and docstatus = 1 and parent not like 'old%'", self.doc.name)
 		if tdsp:
 			msgprint("TDS Payment voucher '%s' has been made against this voucher. Please cancel the payment voucher to proceed." % (tdsp and tdsp[0][0] or ''))
 			raise Exception
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 15dc8a5..9196363 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -635,4 +635,8 @@
 		'patch_module': 'patches.october_2012',
 		'patch_file': 'remove_old_trial_bal',
 	},
+	{
+		'patch_module': 'patches.october_2012',
+		'patch_file': 'fix_cancelled_gl_entries',
+	},
 ]