Included standard charts in json format
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
index a713142..eaa9651 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
@@ -9,6 +9,8 @@
 def create_charts(chart_name, company):
 	chart = get_chart(chart_name)
 
+	frappe.db.sql("delete from `tabAccount` where company=%s", company)
+
 	if chart:
 		accounts = []
 
@@ -45,16 +47,20 @@
 
 					_import_accounts(children, account.name, root_type)
 
-		_import_accounts(chart.get("tree"), None, None, root_account=True)
+		_import_accounts(chart, None, None, root_account=True)
 
 def get_chart(chart_name):
 	chart = {}
-	for fname in os.listdir(os.path.dirname(__file__)):
-		if fname.endswith(".json"):
-			with open(os.path.join(os.path.dirname(__file__), fname), "r") as f:
-				chart = f.read()
-				if chart and json.loads(chart).get("name") == chart_name:
-					return json.loads(chart)
+	if chart_name == "Standard":
+		from erpnext.accounts.doctype.account.chart_of_accounts import standard_chart_of_accounts
+		return standard_chart_of_accounts.coa
+	else:
+		for fname in os.listdir(os.path.dirname(__file__)):
+			if fname.endswith(".json"):
+				with open(os.path.join(os.path.dirname(__file__), fname), "r") as f:
+					chart = f.read()
+					if chart and json.loads(chart).get("name") == chart_name:
+						return json.loads(chart).get("tree")
 
 @frappe.whitelist()
 def get_charts_for_country(country):
@@ -80,4 +86,5 @@
 		with open(os.path.join(os.path.dirname(__file__), "syscohada_syscohada_chart_template.json"), "r") as f:
 			_get_chart_name(f.read())
 
+	charts.append("Standard")
 	return charts
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/standard_chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/standard_chart_of_accounts.py
new file mode 100644
index 0000000..d5d3d5e
--- /dev/null
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/standard_chart_of_accounts.py
@@ -0,0 +1,592 @@
+{
+    "_(\"Accounts Payable\")": {
+        "_(\"Creditors\")": {
+            "account_type": "Payable"
+        }
+    }, 
+    "_(\"Accounts Receivable\")": {
+        "_(\"Debtors\")": {
+            "account_type": "Receivable"
+        }
+    }, 
+    "_(\"Administrative Expenses\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Application of Funds (Assets)\")": {
+        "_(\"Current Assets\")": {
+            "_(\"Accounts Receivable\")": {
+                "_(\"Debtors\")": {
+                    "account_type": "Receivable"
+                }
+            }, 
+            "_(\"Bank Accounts\")": {
+                "account_type": "Bank"
+            }, 
+            "_(\"Cash In Hand\")": {
+                "_(\"Cash\")": {
+                    "account_type": "Cash"
+                }, 
+                "account_type": "Cash"
+            }, 
+            "_(\"Loans and Advances (Assets)\")": {}, 
+            "_(\"Securities and Deposits\")": {
+                "_(\"Earnest Money\")": {}
+            }, 
+            "_(\"Stock Assets\")": {
+                "account_type": "Stock"
+            }, 
+            "_(\"Tax Assets\")": {}
+        }, 
+        "_(\"Fixed Assets\")": {
+            "_(\"Capital Equipments\")": {
+                "account_type": "Fixed Asset"
+            }, 
+            "_(\"Computers\")": {
+                "account_type": "Fixed Asset"
+            }, 
+            "_(\"Furniture and Fixture\")": {
+                "account_type": "Fixed Asset"
+            }, 
+            "_(\"Office Equipments\")": {
+                "account_type": "Fixed Asset"
+            }, 
+            "_(\"Plant and Machinery\")": {
+                "account_type": "Fixed Asset"
+            }
+        }, 
+        "_(\"Investments\")": {}, 
+        "_(\"Temporary Accounts (Assets)\")": {
+            "_(\"Temporary Assets\")": {}
+        }
+    }, 
+    "_(\"Bank Accounts\")": {
+        "account_type": "Bank"
+    }, 
+    "_(\"Bank Overdraft Account\")": {}, 
+    "_(\"Capital Account\")": {
+        "_(\"Reserves and Surplus\")": {}, 
+        "_(\"Shareholders Funds\")": {}
+    }, 
+    "_(\"Capital Equipments\")": {
+        "account_type": "Fixed Asset"
+    }, 
+    "_(\"Cash In Hand\")": {
+        "_(\"Cash\")": {
+            "account_type": "Cash"
+        }, 
+        "account_type": "Cash"
+    }, 
+    "_(\"Cash\")": {
+        "account_type": "Cash"
+    }, 
+    "_(\"Charity and Donations\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Commission on Sales\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Computers\")": {
+        "account_type": "Fixed Asset"
+    }, 
+    "_(\"Cost of Goods Sold\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Creditors\")": {
+        "account_type": "Payable"
+    }, 
+    "_(\"Current Assets\")": {
+        "_(\"Accounts Receivable\")": {
+            "_(\"Debtors\")": {
+                "account_type": "Receivable"
+            }
+        }, 
+        "_(\"Bank Accounts\")": {
+            "account_type": "Bank"
+        }, 
+        "_(\"Cash In Hand\")": {
+            "_(\"Cash\")": {
+                "account_type": "Cash"
+            }, 
+            "account_type": "Cash"
+        }, 
+        "_(\"Loans and Advances (Assets)\")": {}, 
+        "_(\"Securities and Deposits\")": {
+            "_(\"Earnest Money\")": {}
+        }, 
+        "_(\"Stock Assets\")": {
+            "account_type": "Stock"
+        }, 
+        "_(\"Tax Assets\")": {}
+    }, 
+    "_(\"Current Liabilities\")": {}, 
+    "_(\"Debtors\")": {
+        "account_type": "Receivable"
+    }, 
+    "_(\"Depreciation\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Direct Expenses\")": {
+        "_(\"Stock Expenses\")": {
+            "_(\"Cost of Goods Sold\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Expenses Included In Valuation\")": {
+                "account_type": "Expenses Included In Valuation"
+            }, 
+            "_(\"Stock Adjustment\")": {
+                "account_type": "Stock Adjustment"
+            }, 
+            "account_type": "Expense Account"
+        }, 
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Direct Income\")": {
+        "_(\"Sales\")": {
+            "account_type": "Income Account"
+        }, 
+        "_(\"Service\")": {
+            "account_type": "Income Account"
+        }, 
+        "account_type": "Income Account"
+    }, 
+    "_(\"Duties and Taxes\")": {}, 
+    "_(\"Earnest Money\")": {}, 
+    "_(\"Entertainment Expenses\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Expenses Included In Valuation\")": {
+        "account_type": "Expenses Included In Valuation"
+    }, 
+    "_(\"Expenses\")": {
+        "_(\"Direct Expenses\")": {
+            "_(\"Stock Expenses\")": {
+                "_(\"Cost of Goods Sold\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Expenses Included In Valuation\")": {
+                    "account_type": "Expenses Included In Valuation"
+                }, 
+                "_(\"Stock Adjustment\")": {
+                    "account_type": "Stock Adjustment"
+                }, 
+                "account_type": "Expense Account"
+            }, 
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Indirect Expenses\")": {
+            "_(\"Administrative Expenses\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Charity and Donations\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Commission on Sales\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Depreciation\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Entertainment Expenses\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Freight and Forwarding Charges\")": {
+                "account_type": "Chargeable"
+            }, 
+            "_(\"Legal Expenses\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Marketing Expenses\")": {
+                "account_type": "Chargeable"
+            }, 
+            "_(\"Miscellaneous Expenses\")": {
+                "account_type": "Chargeable"
+            }, 
+            "_(\"Office Maintenance Expenses\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Office Rent\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Postal Expenses\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Print and Stationary\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Rounded Off\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Salary\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Sales Expenses\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Telephone Expenses\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Travel Expenses\")": {
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Utility Expenses\")": {
+                "account_type": "Expense Account"
+            }, 
+            "account_type": "Expense Account"
+        }, 
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Fixed Assets\")": {
+        "_(\"Capital Equipments\")": {
+            "account_type": "Fixed Asset"
+        }, 
+        "_(\"Computers\")": {
+            "account_type": "Fixed Asset"
+        }, 
+        "_(\"Furniture and Fixture\")": {
+            "account_type": "Fixed Asset"
+        }, 
+        "_(\"Office Equipments\")": {
+            "account_type": "Fixed Asset"
+        }, 
+        "_(\"Plant and Machinery\")": {
+            "account_type": "Fixed Asset"
+        }
+    }, 
+    "_(\"Freight and Forwarding Charges\")": {
+        "account_type": "Chargeable"
+    }, 
+    "_(\"Furniture and Fixture\")": {
+        "account_type": "Fixed Asset"
+    }, 
+    "_(\"Income\")": {
+        "_(\"Direct Income\")": {
+            "_(\"Sales\")": {
+                "account_type": "Income Account"
+            }, 
+            "_(\"Service\")": {
+                "account_type": "Income Account"
+            }, 
+            "account_type": "Income Account"
+        }, 
+        "_(\"Indirect Income\")": {
+            "account_type": "Income Account"
+        }
+    }, 
+    "_(\"Indirect Expenses\")": {
+        "_(\"Administrative Expenses\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Charity and Donations\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Commission on Sales\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Depreciation\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Entertainment Expenses\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Freight and Forwarding Charges\")": {
+            "account_type": "Chargeable"
+        }, 
+        "_(\"Legal Expenses\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Marketing Expenses\")": {
+            "account_type": "Chargeable"
+        }, 
+        "_(\"Miscellaneous Expenses\")": {
+            "account_type": "Chargeable"
+        }, 
+        "_(\"Office Maintenance Expenses\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Office Rent\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Postal Expenses\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Print and Stationary\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Rounded Off\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Salary\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Sales Expenses\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Telephone Expenses\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Travel Expenses\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Utility Expenses\")": {
+            "account_type": "Expense Account"
+        }, 
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Indirect Income\")": {
+        "account_type": "Income Account"
+    }, 
+    "_(\"Investments\")": {}, 
+    "_(\"Legal Expenses\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Loans (Liabilities)\")": {}, 
+    "_(\"Loans and Advances (Assets)\")": {}, 
+    "_(\"Marketing Expenses\")": {
+        "account_type": "Chargeable"
+    }, 
+    "_(\"Miscellaneous Expenses\")": {
+        "account_type": "Chargeable"
+    }, 
+    "_(\"Office Equipments\")": {
+        "account_type": "Fixed Asset"
+    }, 
+    "_(\"Office Maintenance Expenses\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Office Rent\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Plant and Machinery\")": {
+        "account_type": "Fixed Asset"
+    }, 
+    "_(\"Postal Expenses\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Print and Stationary\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Reserves and Surplus\")": {}, 
+    "_(\"Rounded Off\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Salary\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Sales Expenses\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Sales\")": {
+        "account_type": "Income Account"
+    }, 
+    "_(\"Secured Loans\")": {}, 
+    "_(\"Securities and Deposits\")": {
+        "_(\"Earnest Money\")": {}
+    }, 
+    "_(\"Service\")": {
+        "account_type": "Income Account"
+    }, 
+    "_(\"Shareholders Funds\")": {}, 
+    "_(\"Source of Funds (Liabilities)\")": {
+        "_(\"Capital Account\")": {
+            "_(\"Reserves and Surplus\")": {}, 
+            "_(\"Shareholders Funds\")": {}
+        }, 
+        "_(\"Current Liabilities\")": {}, 
+        "_(\"Temporary Accounts (Liabilities)\")": {
+            "_(\"Temporary Liabilities\")": {}
+        }
+    }, 
+    "_(\"Stock Adjustment\")": {
+        "account_type": "Stock Adjustment"
+    }, 
+    "_(\"Stock Assets\")": {
+        "account_type": "Stock"
+    }, 
+    "_(\"Stock Expenses\")": {
+        "_(\"Cost of Goods Sold\")": {
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Expenses Included In Valuation\")": {
+            "account_type": "Expenses Included In Valuation"
+        }, 
+        "_(\"Stock Adjustment\")": {
+            "account_type": "Stock Adjustment"
+        }, 
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Stock Liabilities\")": {}, 
+    "_(\"Stock Received But Not Billed\")": {
+        "account_type": "Stock Received But Not Billed"
+    }, 
+    "_(\"Tax Assets\")": {}, 
+    "_(\"Telephone Expenses\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Temporary Accounts (Assets)\")": {
+        "_(\"Temporary Assets\")": {}
+    }, 
+    "_(\"Temporary Accounts (Liabilities)\")": {
+        "_(\"Temporary Liabilities\")": {}
+    }, 
+    "_(\"Temporary Assets\")": {}, 
+    "_(\"Temporary Liabilities\")": {}, 
+    "_(\"Travel Expenses\")": {
+        "account_type": "Expense Account"
+    }, 
+    "_(\"Unsecured Loans\")": {}, 
+    "_(\"Utility Expenses\")": {
+        "account_type": "Expense Account"
+    }, 
+    "root": {
+        "_(\"Application of Funds (Assets)\")": {
+            "_(\"Current Assets\")": {
+                "_(\"Accounts Receivable\")": {
+                    "_(\"Debtors\")": {
+                        "account_type": "Receivable"
+                    }
+                }, 
+                "_(\"Bank Accounts\")": {
+                    "account_type": "Bank"
+                }, 
+                "_(\"Cash In Hand\")": {
+                    "_(\"Cash\")": {
+                        "account_type": "Cash"
+                    }, 
+                    "account_type": "Cash"
+                }, 
+                "_(\"Loans and Advances (Assets)\")": {}, 
+                "_(\"Securities and Deposits\")": {
+                    "_(\"Earnest Money\")": {}
+                }, 
+                "_(\"Stock Assets\")": {
+                    "account_type": "Stock"
+                }, 
+                "_(\"Tax Assets\")": {}
+            }, 
+            "_(\"Fixed Assets\")": {
+                "_(\"Capital Equipments\")": {
+                    "account_type": "Fixed Asset"
+                }, 
+                "_(\"Computers\")": {
+                    "account_type": "Fixed Asset"
+                }, 
+                "_(\"Furniture and Fixture\")": {
+                    "account_type": "Fixed Asset"
+                }, 
+                "_(\"Office Equipments\")": {
+                    "account_type": "Fixed Asset"
+                }, 
+                "_(\"Plant and Machinery\")": {
+                    "account_type": "Fixed Asset"
+                }
+            }, 
+            "_(\"Investments\")": {}, 
+            "_(\"Temporary Accounts (Assets)\")": {
+                "_(\"Temporary Assets\")": {}
+            }
+        }, 
+        "_(\"Expenses\")": {
+            "_(\"Direct Expenses\")": {
+                "_(\"Stock Expenses\")": {
+                    "_(\"Cost of Goods Sold\")": {
+                        "account_type": "Expense Account"
+                    }, 
+                    "_(\"Expenses Included In Valuation\")": {
+                        "account_type": "Expenses Included In Valuation"
+                    }, 
+                    "_(\"Stock Adjustment\")": {
+                        "account_type": "Stock Adjustment"
+                    }, 
+                    "account_type": "Expense Account"
+                }, 
+                "account_type": "Expense Account"
+            }, 
+            "_(\"Indirect Expenses\")": {
+                "_(\"Administrative Expenses\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Charity and Donations\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Commission on Sales\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Depreciation\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Entertainment Expenses\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Freight and Forwarding Charges\")": {
+                    "account_type": "Chargeable"
+                }, 
+                "_(\"Legal Expenses\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Marketing Expenses\")": {
+                    "account_type": "Chargeable"
+                }, 
+                "_(\"Miscellaneous Expenses\")": {
+                    "account_type": "Chargeable"
+                }, 
+                "_(\"Office Maintenance Expenses\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Office Rent\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Postal Expenses\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Print and Stationary\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Rounded Off\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Salary\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Sales Expenses\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Telephone Expenses\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Travel Expenses\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "_(\"Utility Expenses\")": {
+                    "account_type": "Expense Account"
+                }, 
+                "account_type": "Expense Account"
+            }, 
+            "account_type": "Expense Account"
+        }, 
+        "_(\"Income\")": {
+            "_(\"Direct Income\")": {
+                "_(\"Sales\")": {
+                    "account_type": "Income Account"
+                }, 
+                "_(\"Service\")": {
+                    "account_type": "Income Account"
+                }, 
+                "account_type": "Income Account"
+            }, 
+            "_(\"Indirect Income\")": {
+                "account_type": "Income Account"
+            }
+        }, 
+        "_(\"Source of Funds (Liabilities)\")": {
+            "_(\"Capital Account\")": {
+                "_(\"Reserves and Surplus\")": {}, 
+                "_(\"Shareholders Funds\")": {}
+            }, 
+            "_(\"Current Liabilities\")": {}, 
+            "_(\"Temporary Accounts (Liabilities)\")": {
+                "_(\"Temporary Liabilities\")": {}
+            }
+        }, 
+        "root_type": "true"
+    }
+}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 274015c..f0130d6 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -49,11 +49,11 @@
 							.format(self.get(field), self.name))
 
 	def on_update(self):
-		if not frappe.db.sql("""select name from tabAccount
-				where company=%s and docstatus<2 limit 1""", self.name):
-			self.create_default_accounts()
-			self.create_default_warehouses()
-			self.install_country_fixtures()
+		# if not frappe.db.sql("""select name from tabAccount
+		# 		where company=%s and docstatus<2 limit 1""", self.name):
+		self.create_default_accounts()
+		self.create_default_warehouses()
+		self.install_country_fixtures()
 
 		if not frappe.db.get_value("Cost Center", {"group_or_ledger": "Ledger", "company": self.name}):
 			self.create_default_cost_center()
@@ -81,11 +81,13 @@
 					}).insert()
 
 	def create_default_accounts(self):
-		if self.chart_of_accounts:
+		if not self.chart_of_accounts:
+			frappe.throw(_("Please select Chart of Accounts"))
+		else:
 			from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts
 			create_charts(self.chart_of_accounts, self.name)
-		else:
-			self.create_standard_accounts()
+		# else:
+		# 	self.create_standard_accounts()
 
 		frappe.db.set(self, "default_receivable_account", frappe.db.get_value("Account",
 			{"company": self.name, "account_type": "Receivable"}))