import chart records into database frm json
This commit is contained in:
parent
a69c30edec
commit
813a93d78d
26
erpnext/accounts/doctype/chart_of_accounts/import_charts.py
Normal file
26
erpnext/accounts/doctype/chart_of_accounts/import_charts.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe, os, json
|
||||||
|
|
||||||
|
def import_charts():
|
||||||
|
frappe.db.sql("""delete from `tabChart of Accounts`""")
|
||||||
|
charts_dir = os.path.join(os.path.dirname(__file__), "charts")
|
||||||
|
for fname in os.listdir(charts_dir):
|
||||||
|
if fname.endswith(".json"):
|
||||||
|
with open(os.path.join(charts_dir, fname), "r") as f:
|
||||||
|
chart = json.loads(f.read())
|
||||||
|
country = frappe.db.get_value("Country", {"code": fname.split("_", 1)[0]})
|
||||||
|
if country:
|
||||||
|
bean = frappe.bean({
|
||||||
|
"doctype":"Chart of Accounts",
|
||||||
|
"chart_name": chart.get("name"),
|
||||||
|
"source_file": fname,
|
||||||
|
"country": country
|
||||||
|
}).insert()
|
||||||
|
print bean.doc.name
|
||||||
|
else:
|
||||||
|
print "No chart for: " + chart.get("name")
|
||||||
|
|
||||||
|
frappe.db.commit()
|
@ -8,6 +8,8 @@ import frappe
|
|||||||
def after_install():
|
def after_install():
|
||||||
import_defaults()
|
import_defaults()
|
||||||
import_country_and_currency()
|
import_country_and_currency()
|
||||||
|
from erpnext.accounts.doctype.chart_of_accounts.import_charts import import_charts
|
||||||
|
import_charts()
|
||||||
frappe.db.set_value('Control Panel', None, 'home_page', 'setup-wizard')
|
frappe.db.set_value('Control Panel', None, 'home_page', 'setup-wizard')
|
||||||
feature_setup()
|
feature_setup()
|
||||||
from erpnext.setup.page.setup_wizard.setup_wizard import add_all_roles_to
|
from erpnext.setup.page.setup_wizard.setup_wizard import add_all_roles_to
|
||||||
@ -24,6 +26,7 @@ def import_country_and_currency():
|
|||||||
frappe.doc({
|
frappe.doc({
|
||||||
"doctype": "Country",
|
"doctype": "Country",
|
||||||
"country_name": name,
|
"country_name": name,
|
||||||
|
"code": country.code,
|
||||||
"date_format": country.date_format or "dd-mm-yyyy",
|
"date_format": country.date_format or "dd-mm-yyyy",
|
||||||
"time_zones": "\n".join(country.timezones or [])
|
"time_zones": "\n".join(country.timezones or [])
|
||||||
}).insert()
|
}).insert()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user