Fix patches for Travis
diff --git a/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py b/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py
index 481c557..a9078e3 100644
--- a/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py
+++ b/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py
@@ -21,7 +21,8 @@
 	frappe.reload_doc('stock', 'doctype', 'delivery_note')
 
 	for doctype in to_rename:
-		rename_field(doctype, 'subscription', 'auto_repeat')
+		if frappe.db.has_column(doctype, 'subscription'):
+			rename_field(doctype, 'subscription', 'auto_repeat')
 
 	subscriptions = frappe.db.sql('select * from `tabSubscription`', as_dict=1)
 
diff --git a/erpnext/patches/v11_0/create_department_records_for_each_company.py b/erpnext/patches/v11_0/create_department_records_for_each_company.py
index bef524c..2018ffd 100644
--- a/erpnext/patches/v11_0/create_department_records_for_each_company.py
+++ b/erpnext/patches/v11_0/create_department_records_for_each_company.py
@@ -2,7 +2,7 @@
 from frappe.utils.nestedset import rebuild_tree
 
 def execute():
-	for doctype in ['department', 'leave_period', 'staffing_plan', 'job_opening']:
+	for doctype in ['department', 'leave_period', 'staffing_plan', 'job_opening', 'payroll_entry']:
 		frappe.reload_doc("hr", "doctype", doctype)
 
 	companies = frappe.db.get_all("Company", fields=["name", "abbr"])
diff --git a/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py b/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py
index 18622f2..4adae49 100644
--- a/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py
+++ b/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py
@@ -11,6 +11,7 @@
 	frappe.reload_doc('assets', 'doctype', 'asset_category')
 	frappe.reload_doc('assets', 'doctype', 'asset')
 	frappe.reload_doc('assets', 'doctype', 'asset_movement')
+	frappe.reload_doc('assets', 'doctype', 'asset_category_account')
 
 	frappe.db.sql(""" update `tabAsset` ast, `tabWarehouse` wh
 		set ast.location = wh.warehouse_name where ast.warehouse = wh.name""")
@@ -36,8 +37,8 @@
 	frappe.db.sql(""" update `tabDepreciation Schedule` ds, `tabAsset` ast 
 		set ds.depreciation_method = ast.depreciation_method, ds.finance_book_id = 1 where ds.parent = ast.name """)
 
-	for catergory in frappe.get_all('Asset Category'):
-		asset_category_doc = frappe.get_doc("Asset Category", catergory)
+	for category in frappe.get_all('Asset Category'):
+		asset_category_doc = frappe.get_doc("Asset Category", category)
 		row = asset_category_doc.append('finance_books', {
 			'depreciation_method': asset_category_doc.depreciation_method,
 			'total_number_of_depreciations': asset_category_doc.total_number_of_depreciations,
diff --git a/erpnext/patches/v11_0/rename_field_max_days_allowed.py b/erpnext/patches/v11_0/rename_field_max_days_allowed.py
index e0acf06..0356726 100644
--- a/erpnext/patches/v11_0/rename_field_max_days_allowed.py
+++ b/erpnext/patches/v11_0/rename_field_max_days_allowed.py
@@ -2,6 +2,7 @@
 from frappe.model.utils.rename_field import rename_field
 
 def execute():
+	frappe.db.sql("""update `tabLeave Type` set max_days_allowed = '0' where trim(coalesce(max_days_allowed, '')) = ''""")
 	frappe.reload_doc("hr", "doctype", "leave_type")
 	frappe.db.sql_ddl("""ALTER table `tabLeave Type` modify max_days_allowed int(8) NOT NULL""")
 	rename_field("Leave Type", "max_days_allowed", "max_continuous_days_allowed") 
diff --git a/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py b/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py
index 4308526..b5172db 100644
--- a/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py
+++ b/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py
@@ -3,6 +3,8 @@
 def execute():
 	frappe.reload_doc('hr', 'doctype', 'salary_structure')
 	frappe.reload_doc('hr', 'doctype', 'salary_structure_employee')
+	if not frappe.db.has_column('Salary Structure', 'employees'):
+		return
 	for ss in frappe.db.sql(""" select employee, name from `tabSalary Structure`""", as_dict=True):
 		ss_doc = frappe.get_doc('Salary Structure', ss.name)
 		salary_employee = ss_doc.append('employees',{})
diff --git a/erpnext/patches/v7_1/update_missing_salary_component_type.py b/erpnext/patches/v7_1/update_missing_salary_component_type.py
index 25624f5..7d50ee4 100644
--- a/erpnext/patches/v7_1/update_missing_salary_component_type.py
+++ b/erpnext/patches/v7_1/update_missing_salary_component_type.py
@@ -10,6 +10,8 @@
 
 def execute():
 	frappe.reload_doc("accounts", "doctype", "salary_component_account")
+	frappe.reload_doc("hr", "doctype", "salary_component")
+	frappe.reload_doc("hr", "doctype", "taxable_salary_slab")
 	
 	for s in frappe.db.sql('''select name, type, salary_component_abbr from `tabSalary Component` 
 			where ifnull(type, "")="" or ifnull(salary_component_abbr, "") = ""''', as_dict=1):
diff --git a/erpnext/patches/v8_0/update_production_orders.py b/erpnext/patches/v8_0/update_production_orders.py
index 7d87d68..8e993cc 100644
--- a/erpnext/patches/v8_0/update_production_orders.py
+++ b/erpnext/patches/v8_0/update_production_orders.py
@@ -10,6 +10,9 @@
 		"BOM Item", "BOM Explosion Item", "BOM"):
 			frappe.reload_doctype(doctype)
 
+	frappe.reload_doc("stock", "doctype", "item")
+	frappe.reload_doc("stock", "doctype", "item_default")
+
 	# fetch all draft and submitted work orders
 	fields = ["name"]
 	if "source_warehouse" in frappe.db.get_table_columns("Work Order"):
diff --git a/erpnext/patches/v9_0/fix_subscription_next_date.py b/erpnext/patches/v9_0/fix_subscription_next_date.py
index ac9db31..1789848 100644
--- a/erpnext/patches/v9_0/fix_subscription_next_date.py
+++ b/erpnext/patches/v9_0/fix_subscription_next_date.py
@@ -7,12 +7,17 @@
 from frappe.desk.doctype.auto_repeat.auto_repeat import get_next_schedule_date
 
 def execute():
-	frappe.reload_doctype('Subscription')
+	frappe.reload_doc('accounts', 'doctype', 'subscription')
+	fields = ["name", "reference_doctype", "reference_document",
+			"start_date", "frequency", "repeat_on_day"]
+
+	for d in fields:
+		if not frappe.db.has_column('Subscription', d):
+			return
 
 	doctypes = ('Purchase Order', 'Sales Order', 'Purchase Invoice', 'Sales Invoice')
 	for data in frappe.get_all('Subscription',
-		fields = ["name", "reference_doctype", "reference_document",
-			"start_date", "frequency", "repeat_on_day"],
+		fields = fields,
 		filters = {'reference_doctype': ('in', doctypes), 'docstatus': 1}):
 
 		recurring_id = frappe.db.get_value(data.reference_doctype, data.reference_document, "recurring_id")