Merge branch 'develop'
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index 7d2298f..721b475 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1,2 +1,2 @@
 from __future__ import unicode_literals
-__version__ = '5.0.5'
+__version__ = '5.0.6'
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index aa8638e..c16d9b1 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -5,7 +5,7 @@
 app_description = "Open Source Enterprise Resource Planning for Small and Midsized Organizations"
 app_icon = "icon-th"
 app_color = "#e74c3c"
-app_version = "5.0.5"
+app_version = "5.0.6"
 
 error_report_email = "support@erpnext.com"
 
diff --git a/erpnext/patches/v4_2/party_model.py b/erpnext/patches/v4_2/party_model.py
index ad56109..cbb00cf 100644
--- a/erpnext/patches/v4_2/party_model.py
+++ b/erpnext/patches/v4_2/party_model.py
@@ -96,15 +96,16 @@
 				frappe.db.commit()
 
 def delete_individual_party_account():
-	frappe.db.sql("""delete from `tabAccount` acc 
-		where ifnull(acc.master_type, '') in ('Customer', 'Supplier')
-		and ifnull(acc.master_name, '') != '' 
-		and not exists(select gle.name from `tabGL Entry` gle where gle.account = acc.name)""")
+	frappe.db.sql("""delete from `tabAccount` 
+		where ifnull(master_type, '') in ('Customer', 'Supplier') 
+			and ifnull(master_name, '') != '' 
+			and not exists(select gle.name from `tabGL Entry` gle 
+				where gle.account = tabAccount.name)""")
 		
-	accounts_not_deleted = frappe.db.sql_list("""select name from `tabAccount` acc 
-		where ifnull(acc.master_type, '') in ('Customer', 'Supplier')
-		and ifnull(acc.master_name, '') != '' 
-		and exists(select gle.name from `tabGL Entry` gle where gle.account = acc.name)""")
+	accounts_not_deleted = frappe.db.sql_list("""select tabAccount.name from `tabAccount` 
+		where ifnull(master_type, '') in ('Customer', 'Supplier')
+		and ifnull(master_name, '') != '' 
+		and exists(select gle.name from `tabGL Entry` gle where gle.account = tabAccount.name)""")
 		
 	if accounts_not_deleted:
 		print "Accounts not deleted: " + "\n".join(accounts_not_deleted)
diff --git a/setup.py b/setup.py
index 669c901..31eea3d 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 from setuptools import setup, find_packages
 
-version = "5.0.5"
+version = "5.0.6"
 
 with open("requirements.txt", "r") as f:
 	install_requires = f.readlines()