Merge branch 'hotfix'
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 1c78709..636bfe9 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -4,7 +4,7 @@
 import frappe
 from erpnext.hooks import regional_overrides
 
-__version__ = '9.0.1'
+__version__ = '9.0.2'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/tax_rule/tax_rule.py b/erpnext/accounts/doctype/tax_rule/tax_rule.py
index 2d91a3c..9c091e8 100644
--- a/erpnext/accounts/doctype/tax_rule/tax_rule.py
+++ b/erpnext/accounts/doctype/tax_rule/tax_rule.py
@@ -8,6 +8,7 @@
 from frappe.model.document import Document
 from frappe.utils import cstr, cint
 from frappe.contacts.doctype.address.address import get_default_address
+from frappe.utils.nestedset import get_root_of
 from erpnext.setup.doctype.customer_group.customer_group import get_parent_customer_groups
 
 class IncorrectCustomerGroup(frappe.ValidationError): pass
@@ -136,7 +137,7 @@
 		if key=="use_for_shopping_cart":
 			conditions.append("use_for_shopping_cart = {0}".format(1 if value else 0))
 		if key == 'customer_group':
-			if not value: value = _("All Customer Groups")
+			if not value: value = get_root_of("Customer Group")
 			customer_group_condition = get_customer_group_condition(value)
 			conditions.append("ifnull({0}, '') in ('', {1})".format(key, customer_group_condition))
 		else:
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 19d713e..c6bd9ec 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -408,6 +408,8 @@
 erpnext.patches.v8_0.update_sales_cost_in_project
 erpnext.patches.v8_0.save_system_settings
 erpnext.patches.v8_1.delete_deprecated_reports
+erpnext.patches.v9_0.remove_subscription_module
+erpnext.patches.v8_7.make_subscription_from_recurring_data
 erpnext.patches.v8_1.setup_gst_india #2017-06-27
 execute:frappe.reload_doc('regional', 'doctype', 'gst_hsn_code')
 erpnext.patches.v8_1.removed_roles_from_gst_report_non_indian_account
@@ -439,8 +441,6 @@
 erpnext.patches.v8_9.add_setup_progress_actions #08-09-2017 #26-09-2017
 erpnext.patches.v8_9.rename_company_sales_target_field
 erpnext.patches.v8_8.set_bom_rate_as_per_uom
-erpnext.patches.v9_0.remove_subscription_module
-erpnext.patches.v8_7.make_subscription_from_recurring_data
 erpnext.patches.v8_9.set_print_zero_amount_taxes
 erpnext.patches.v8_9.set_default_customer_group
 erpnext.patches.v8_9.remove_employee_from_salary_structure_parent
diff --git a/erpnext/patches/v8_7/make_subscription_from_recurring_data.py b/erpnext/patches/v8_7/make_subscription_from_recurring_data.py
index ab0fc12..c5d7d72 100644
--- a/erpnext/patches/v8_7/make_subscription_from_recurring_data.py
+++ b/erpnext/patches/v8_7/make_subscription_from_recurring_data.py
@@ -8,9 +8,15 @@
 def execute():
 	frappe.reload_doc('accounts', 'doctype', 'subscription')
 	frappe.reload_doc('selling', 'doctype', 'sales_order')
+	frappe.reload_doc('selling', 'doctype', 'quotation')
 	frappe.reload_doc('buying', 'doctype', 'purchase_order')
+	frappe.reload_doc('buying', 'doctype', 'supplier_quotation')
 	frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
 	frappe.reload_doc('accounts', 'doctype', 'purchase_invoice')
+	frappe.reload_doc('stock', 'doctype', 'purchase_receipt')
+	frappe.reload_doc('stock', 'doctype', 'delivery_note')
+	frappe.reload_doc('accounts', 'doctype', 'journal_entry')
+	frappe.reload_doc('accounts', 'doctype', 'payment_entry')
 
 	for doctype in ['Sales Order', 'Sales Invoice',
 		'Purchase Invoice', 'Purchase Invoice']:
diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py
index 106a3d5..2798cfb 100644
--- a/erpnext/regional/india/setup.py
+++ b/erpnext/regional/india/setup.py
@@ -12,7 +12,7 @@
 	make_custom_fields()
 	add_permissions()
 	add_custom_roles_for_reports()
-	add_hsn_sac_codes()
+	frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes')
 	add_print_formats()
 	if not patch:
 		update_address_template()
@@ -47,12 +47,14 @@
 
 def create_hsn_codes(data, code_field):
 	for d in data:
-		if not frappe.db.exists("GST HSN Code", d[code_field]):
-			hsn_code = frappe.new_doc('GST HSN Code')
-			hsn_code.description = d["description"]
-			hsn_code.hsn_code = d[code_field]
-			hsn_code.name = d[code_field]
+		hsn_code = frappe.new_doc('GST HSN Code')
+		hsn_code.description = d["description"]
+		hsn_code.hsn_code = d[code_field]
+		hsn_code.name = d[code_field]
+		try:
 			hsn_code.db_insert()
+		except frappe.DuplicateEntryError:
+			pass
 
 def add_custom_roles_for_reports():
 	for report_name in ('GST Sales Register', 'GST Purchase Register',
diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py
index a2e4c57..043dc73 100644
--- a/erpnext/stock/doctype/batch/batch.py
+++ b/erpnext/stock/doctype/batch/batch.py
@@ -103,14 +103,15 @@
 def set_batch_nos(doc, warehouse_field, throw = False):
 	'''Automatically select `batch_no` for outgoing items in item table'''
 	for d in doc.items:
+		qty = d.get('stock_qty') or d.get('qty') or 0
 		has_batch_no = frappe.db.get_value('Item', d.item_code, 'has_batch_no')
 		warehouse = d.get(warehouse_field, None)
-		if has_batch_no and warehouse and d.stock_qty > 0:
+		if has_batch_no and warehouse and qty > 0:
 			if not d.batch_no:
-				d.batch_no = get_batch_no(d.item_code, warehouse, d.stock_qty, throw)
+				d.batch_no = get_batch_no(d.item_code, warehouse, qty, throw)
 			else:
 				batch_qty = get_batch_qty(batch_no=d.batch_no, warehouse=warehouse)
-				if flt(batch_qty) < flt(d.stock_qty):
+				if flt(batch_qty) < flt(qty):
 					frappe.throw(_("Row #{0}: The batch {1} has only {2} qty. Please select another batch which has {3} qty available or split the row into multiple rows, to deliver/issue from multiple batches").format(d.idx, d.batch_no, batch_qty, d.qty))
 
 def get_batch_no(item_code, warehouse, qty, throw=False):