Merge pull request #14247 from rohitwaghchaure/patch_fixed_for_asset_warehouse

Fixed patch, checked warehouse available in the asset
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 4adae49..1c8bd68 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
@@ -13,36 +13,37 @@
 	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""")
+	if frappe.db.has_column("Asset", "warehouse"):
+		frappe.db.sql(""" update `tabAsset` ast, `tabWarehouse` wh
+			set ast.location = wh.warehouse_name where ast.warehouse = wh.name""")
 
-	frappe.db.sql(""" update `tabAsset Movement` ast_mv
-		set ast_mv.source_location = (select warehouse_name from `tabWarehouse` where name = ast_mv.source_warehouse),
-		ast_mv.target_location = (select warehouse_name from `tabWarehouse` where name = ast_mv.target_warehouse)""")
+		frappe.db.sql(""" update `tabAsset Movement` ast_mv
+			set ast_mv.source_location = (select warehouse_name from `tabWarehouse` where name = ast_mv.source_warehouse),
+			ast_mv.target_location = (select warehouse_name from `tabWarehouse` where name = ast_mv.target_warehouse)""")
 
-	for d in frappe.get_all('Asset'):
-		doc = frappe.get_doc('Asset', d.name)
-		if doc.calculate_depreciation:
-			fb = doc.append('finance_books', {
-				'depreciation_method': doc.depreciation_method,
-				'total_number_of_depreciations': doc.total_number_of_depreciations,
-				'frequency_of_depreciation': doc.frequency_of_depreciation,
-				'depreciation_start_date': doc.next_depreciation_date,
-				'expected_value_after_useful_life': doc.expected_value_after_useful_life,
-				'value_after_depreciation': doc.value_after_depreciation
+		for d in frappe.get_all('Asset'):
+			doc = frappe.get_doc('Asset', d.name)
+			if doc.calculate_depreciation:
+				fb = doc.append('finance_books', {
+					'depreciation_method': doc.depreciation_method,
+					'total_number_of_depreciations': doc.total_number_of_depreciations,
+					'frequency_of_depreciation': doc.frequency_of_depreciation,
+					'depreciation_start_date': doc.next_depreciation_date,
+					'expected_value_after_useful_life': doc.expected_value_after_useful_life,
+					'value_after_depreciation': doc.value_after_depreciation
+				})
+
+				fb.db_update()
+
+		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 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,
+				'frequency_of_depreciation': asset_category_doc.frequency_of_depreciation
 			})
 
-			fb.db_update()
-
-	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 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,
-			'frequency_of_depreciation': asset_category_doc.frequency_of_depreciation
-		})
-
-		row.db_update()
\ No newline at end of file
+			row.db_update()
\ No newline at end of file