[enhance] rename warehouse account type to stock
diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js
index b2eef20..9364b59 100644
--- a/erpnext/accounts/doctype/account/account.js
+++ b/erpnext/accounts/doctype/account/account.js
@@ -41,7 +41,7 @@
 cur_frm.cscript.account_type = function(doc, cdt, cdn) {
 	if(doc.is_group==0) {
 		cur_frm.toggle_display(['tax_rate'], doc.account_type == 'Tax');
-		cur_frm.toggle_display('warehouse', doc.account_type=='Warehouse');
+		cur_frm.toggle_display('warehouse', doc.account_type=='Stock');
 	}
 }
 
diff --git a/erpnext/accounts/doctype/account/account.json b/erpnext/accounts/doctype/account/account.json
index 8fc7b55..f11a664 100644
--- a/erpnext/accounts/doctype/account/account.json
+++ b/erpnext/accounts/doctype/account/account.json
@@ -2,6 +2,7 @@
  "allow_copy": 1, 
  "allow_import": 1, 
  "allow_rename": 1, 
+ "beta": 0, 
  "creation": "2013-01-30 12:49:46", 
  "custom": 0, 
  "description": "Heads (or groups) against which Accounting Entries are made and balances are maintained.", 
@@ -282,7 +283,7 @@
    "no_copy": 0, 
    "oldfieldname": "account_type", 
    "oldfieldtype": "Select", 
-   "options": "\nAccumulated Depreciation\nBank\nCash\nChargeable\nCost of Goods Sold\nDepreciation\nEquity\nExpense Account\nExpenses Included In Valuation\nFixed Asset\nIncome Account\nPayable\nReceivable\nRound Off\nStock\nStock Adjustment\nStock Received But Not Billed\nTax\nTemporary\nWarehouse", 
+   "options": "\nAccumulated Depreciation\nBank\nCash\nChargeable\nCost of Goods Sold\nDepreciation\nEquity\nExpense Account\nExpenses Included In Valuation\nFixed Asset\nIncome Account\nPayable\nReceivable\nRound Off\nStock\nStock Adjustment\nStock Received But Not Billed\nTax\nTemporary", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -475,13 +476,14 @@
  "hide_toolbar": 0, 
  "icon": "icon-money", 
  "idx": 1, 
+ "image_view": 0, 
  "in_create": 0, 
  "in_dialog": 0, 
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-03-31 05:15:51.062604", 
+ "modified": "2016-06-24 13:33:45.504882", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Account", 
@@ -588,6 +590,7 @@
    "write": 1
   }
  ], 
+ "quick_entry": 0, 
  "read_only": 0, 
  "read_only_onload": 0, 
  "search_fields": "", 
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index 83517ce..9520928 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -164,20 +164,21 @@
 	def validate_warehouse_account(self):
 		if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
 			return
-
-		if self.account_type == "Warehouse":
+			
+		if self.account_type == "Stock" and not self.is_group:
 			if not self.warehouse:
-				throw(_("Warehouse is mandatory if account type is Warehouse"))
-
-			old_warehouse = frappe.db.get_value("Account", self.name, "warehouse")
-			if old_warehouse != self.warehouse:
+				throw(_("Warehouse is mandatory"))
+				
+			old_warehouse = cstr(frappe.db.get_value("Account", self.name, "warehouse"))
+			if old_warehouse != cstr(self.warehouse):
 				if old_warehouse:
 					self.validate_warehouse(old_warehouse)
 				if self.warehouse:
 					self.validate_warehouse(self.warehouse)
+					
 		elif self.warehouse:
 			self.warehouse = None
-
+	
 	def validate_warehouse(self, warehouse):
 		lft, rgt = frappe.db.get_value("Warehouse", warehouse, ["lft", "rgt"])
 
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index be9a884..21b09c4 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -99,7 +99,7 @@
 	if cint(frappe.db.get_single_value("Accounts Settings", "auto_accounting_for_stock")) \
 		and gl_map[0].voucher_type=="Journal Entry":
 			aii_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
-				where account_type = 'Warehouse' and (warehouse != '' and warehouse is not null)""")]
+				where account_type = 'Stock' and (warehouse != '' and warehouse is not null)""")]
 
 			for entry in gl_map:
 				if entry.account in aii_accounts:
diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py
index 681e563..3407526 100644
--- a/erpnext/accounts/report/cash_flow/cash_flow.py
+++ b/erpnext/accounts/report/cash_flow/cash_flow.py
@@ -19,7 +19,7 @@
 			{"account_type": "Depreciation", "label": _("Depreciation")},
 			{"account_type": "Receivable", "label": _("Net Change in Accounts Receivable")},
 			{"account_type": "Payable", "label": _("Net Change in Accounts Payable")},
-			{"account_type": "Warehouse", "label": _("Net Change in Inventory")}
+			{"account_type": "Stock", "label": _("Net Change in Inventory")}
 		]
 	}
 
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index fbead26..d2cfb78 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -318,7 +318,7 @@
 	difference = {}
 
 	account_warehouse = dict(frappe.db.sql("""select name, warehouse from tabAccount
-		where account_type = 'Warehouse' and (warehouse is not null and warehouse != '')
+		where account_type = 'Stock' and (warehouse is not null and warehouse != '')
 		and name in (%s)""" % ', '.join(['%s']*len(account_list)), account_list))
 
 	for account, warehouse in account_warehouse.items():
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 1e685e5..e0420d6 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -321,7 +321,7 @@
 	warehouse_account = frappe._dict()
 
 	for d in frappe.db.sql("""select warehouse, name, account_currency from tabAccount
-		where account_type = 'Warehouse' and (warehouse is not null and warehouse != ''
+		where account_type = 'Stock' and (warehouse is not null and warehouse != ''
 		and is_group != 1)""", as_dict=1):
 			warehouse_account.setdefault(d.warehouse, d)
 	return warehouse_account
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 23f041c..5c1fc2d 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -275,3 +275,4 @@
 erpnext.patches.v7_0.re_route
 erpnext.patches.v7_0.create_warehouse_nestedset
 erpnext.patches.v7_0.system_settings_setup_complete
+erpnext.patches.v7_0.merge_account_type_stock_and_warehouse_to_stock
diff --git a/erpnext/patches/v7_0/merge_account_type_stock_and_warehouse_to_stock.py b/erpnext/patches/v7_0/merge_account_type_stock_and_warehouse_to_stock.py
new file mode 100644
index 0000000..6141792
--- /dev/null
+++ b/erpnext/patches/v7_0/merge_account_type_stock_and_warehouse_to_stock.py
@@ -0,0 +1,9 @@
+import frappe
+
+def execute():
+	frappe.reload_doc("accounts", "doctype", "account")
+	
+	frappe.db.sql(""" update tabAccount set account_type = "Stock"
+		where account_type = "Warehouse" """)
+	
+	frappe.db.commit()
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
index 24d0546..30f2a06 100644
--- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
@@ -127,7 +127,7 @@
 		mr = make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC",
 			qty=50, basic_rate=100, expense_account="Stock Adjustment - _TC")
 					
-		stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Warehouse",
+		stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Stock",
 			"warehouse": mr.get("items")[0].t_warehouse})
 
 		self.check_stock_ledger_entries("Stock Entry", mr.name,
@@ -160,7 +160,7 @@
 		self.check_stock_ledger_entries("Stock Entry", mi.name,
 			[["_Test Item", "_Test Warehouse - _TC", -40.0]])
 
-		stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Warehouse",
+		stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Stock",
 			"warehouse": "_Test Warehouse - _TC"})
 
 		stock_value_diff = abs(frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Stock Entry",
@@ -192,10 +192,10 @@
 		self.check_stock_ledger_entries("Stock Entry", mtn.name,
 			[["_Test Item", "_Test Warehouse - _TC", -45.0], ["_Test Item", "_Test Warehouse 1 - _TC", 45.0]])
 
-		stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Warehouse",
+		stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Stock",
 			"warehouse": mtn.get("items")[0].s_warehouse})
 
-		fixed_asset_account = frappe.db.get_value("Account", {"account_type": "Warehouse",
+		fixed_asset_account = frappe.db.get_value("Account", {"account_type": "Stock",
 			"warehouse": mtn.get("items")[0].t_warehouse})
 
 		stock_value_diff = abs(frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Stock Entry",
@@ -260,7 +260,7 @@
 		repack.insert()
 		repack.submit()
 
-		stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Warehouse",
+		stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Stock",
 			"warehouse": repack.get("items")[1].t_warehouse})
 
 		rm_stock_value_diff = abs(frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Stock Entry",
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index 57da471..cd09545 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -18,7 +18,7 @@
 	def onload(self):
 		'''load account name for General Ledger Report'''
 		account = frappe.db.get_value("Account", {
-			"account_type": "Warehouse", "company": self.company, "warehouse": self.name})
+			"account_type": "Stock", "company": self.company, "warehouse": self.name, "is_group": 0})
 
 		if account:
 			self.set_onload('account', account)
@@ -36,7 +36,7 @@
 				self.validate_parent_account()
 
 				warehouse_account = frappe.db.get_value("Account",
-					{"account_type": "Warehouse", "company": self.company, "warehouse": self.name},
+					{"account_type": "Stock", "company": self.company, "warehouse": self.name, "is_group": 0},
 					["name", "parent_account"])
 
 				if warehouse_account and warehouse_account[1] != self.create_account_under:
@@ -61,7 +61,7 @@
 							else self.create_account_under,
 						'is_group': 1 if self.is_group=="Yes" else 0 ,
 						'company':self.company,
-						"account_type": "Warehouse",
+						"account_type": "Stock",
 						"warehouse": self.name,
 						"freeze_account": "No"
 					})
@@ -152,8 +152,8 @@
 		return get_name_with_abbr(dn, self.company)
 
 	def get_account(self, warehouse):
-		return frappe.db.get_value("Account", {"account_type": "Warehouse",
-			"warehouse": warehouse, "company": self.company})
+		return frappe.db.get_value("Account", {"account_type": "Stock",
+			"warehouse": warehouse, "company": self.company, "is_group": 0})
 
 	def after_rename(self, olddn, newdn, merge=False):
 		if merge:
diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py
index 7d92813..61f799b 100644
--- a/erpnext/stock/stock_balance.py
+++ b/erpnext/stock/stock_balance.py
@@ -231,7 +231,7 @@
 
 def repost_all_stock_vouchers():
 	warehouses_with_account = frappe.db.sql_list("""select master_name from tabAccount
-		where ifnull(account_type, '') = 'Warehouse'""")
+		where ifnull(account_type, '') = 'Stock' and (warehouse is not null and warehouse != '') """)
 
 	vouchers = frappe.db.sql("""select distinct voucher_type, voucher_no
 		from `tabStock Ledger Entry` sle