diff --git a/erpnext/setup/doctype/company/charts/__init__.py b/erpnext/accounts/doctype/chart_of_accounts/__init__.py similarity index 100% rename from erpnext/setup/doctype/company/charts/__init__.py rename to erpnext/accounts/doctype/chart_of_accounts/__init__.py diff --git a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py new file mode 100644 index 00000000000..faf193a107a --- /dev/null +++ b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py @@ -0,0 +1,34 @@ +# 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 + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl + + def create_accounts(self, company): + with open(os.path.join(os.path.dirname(__file__), "charts", + self.doc.source_file), "r") as f: + chart = json.loads(f.read()) + + def _import_accounts(children, parent): + for child in children: + print child.get("name"), parent + account = frappe.bean({ + "doctype": "Account", + "account_name": child.get("name"), + "company": company, + "parent_account": parent, + "group_or_ledger": "Group" if child.get("children") else "Ledger", + "root_type": child.get("root_type"), + "is_pl_account": "Yes" if child.get("root_type") in ["Expense", "Income"] \ + else "No", + "account_type": child.get("account_type") + }).insert() + + if child.get("children"): + _import_accounts(child.get("children"), account.doc.name) + + _import_accounts(chart.get("root").get("children"), None) \ No newline at end of file diff --git a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.txt b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.txt new file mode 100644 index 00000000000..fc2a742791d --- /dev/null +++ b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.txt @@ -0,0 +1,78 @@ +[ + { + "creation": "2014-03-05 14:11:31", + "docstatus": 0, + "modified": "2014-03-05 14:51:05", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "autoname": "field:chart_name", + "description": "Financial Chart of Accounts. Imported from file.", + "doctype": "DocType", + "document_type": "Master", + "in_create": 1, + "module": "Accounts", + "name": "__common__" + }, + { + "doctype": "DocField", + "name": "__common__", + "parent": "Chart of Accounts", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0 + }, + { + "doctype": "DocPerm", + "export": 0, + "name": "__common__", + "parent": "Chart of Accounts", + "parentfield": "permissions", + "parenttype": "DocType", + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager" + }, + { + "doctype": "DocType", + "name": "Chart of Accounts" + }, + { + "doctype": "DocField", + "fieldname": "chart_name", + "fieldtype": "Data", + "in_list_view": 0, + "label": "Chart Name", + "reqd": 1 + }, + { + "doctype": "DocField", + "fieldname": "country", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Country", + "options": "Country", + "reqd": 1 + }, + { + "doctype": "DocField", + "fieldname": "preview", + "fieldtype": "HTML", + "label": "Preview" + }, + { + "doctype": "DocField", + "fieldname": "source_file", + "fieldtype": "Data", + "hidden": 1, + "label": "Source File", + "read_only": 1, + "reqd": 0 + }, + { + "doctype": "DocPerm" + } +] \ No newline at end of file diff --git a/erpnext/accounts/doctype/chart_of_accounts/charts/__init__.py b/erpnext/accounts/doctype/chart_of_accounts/charts/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/setup/doctype/company/charts/ar_ar_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/ar_ar_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/ar_ar_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/ar_ar_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/at_austria_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/at_austria_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/at_austria_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/at_austria_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/be_l10nbe_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/be_l10nbe_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/be_l10nbe_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/be_l10nbe_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/bo_bo_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/bo_bo_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/bo_bo_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/bo_bo_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/ca_ca_en_chart_template_en.json b/erpnext/accounts/doctype/chart_of_accounts/charts/ca_ca_en_chart_template_en.json similarity index 100% rename from erpnext/setup/doctype/company/charts/ca_ca_en_chart_template_en.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/ca_ca_en_chart_template_en.json diff --git a/erpnext/setup/doctype/company/charts/ca_ca_fr_chart_template_fr.json b/erpnext/accounts/doctype/chart_of_accounts/charts/ca_ca_fr_chart_template_fr.json similarity index 100% rename from erpnext/setup/doctype/company/charts/ca_ca_fr_chart_template_fr.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/ca_ca_fr_chart_template_fr.json diff --git a/erpnext/setup/doctype/company/charts/cl_cl_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/cl_cl_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/cl_cl_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/cl_cl_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/cn_l10n_chart_china.json b/erpnext/accounts/doctype/chart_of_accounts/charts/cn_l10n_chart_china.json similarity index 100% rename from erpnext/setup/doctype/company/charts/cn_l10n_chart_china.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/cn_l10n_chart_china.json diff --git a/erpnext/setup/doctype/company/charts/de_l10n_chart_de_skr04.json b/erpnext/accounts/doctype/chart_of_accounts/charts/de_l10n_chart_de_skr04.json similarity index 100% rename from erpnext/setup/doctype/company/charts/de_l10n_chart_de_skr04.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/de_l10n_chart_de_skr04.json diff --git a/erpnext/setup/doctype/company/charts/de_l10n_de_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/de_l10n_de_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/de_l10n_de_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/de_l10n_de_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/ec_ec_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/ec_ec_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/ec_ec_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/ec_ec_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/es_l10nES_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/es_l10nES_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/es_l10nES_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/es_l10nES_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/es_l10nES_chart_template_assoc.json b/erpnext/accounts/doctype/chart_of_accounts/charts/es_l10nES_chart_template_assoc.json similarity index 100% rename from erpnext/setup/doctype/company/charts/es_l10nES_chart_template_assoc.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/es_l10nES_chart_template_assoc.json diff --git a/erpnext/setup/doctype/company/charts/es_l10nES_chart_template_pymes.json b/erpnext/accounts/doctype/chart_of_accounts/charts/es_l10nES_chart_template_pymes.json similarity index 100% rename from erpnext/setup/doctype/company/charts/es_l10nES_chart_template_pymes.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/es_l10nES_chart_template_pymes.json diff --git a/erpnext/setup/doctype/company/charts/fr_l10n_fr_pcg_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/fr_l10n_fr_pcg_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/fr_l10n_fr_pcg_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/fr_l10n_fr_pcg_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/gr_l10n_gr_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/gr_l10n_gr_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/gr_l10n_gr_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/gr_l10n_gr_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/hn_cuentas_plantilla.json b/erpnext/accounts/doctype/chart_of_accounts/charts/hn_cuentas_plantilla.json similarity index 100% rename from erpnext/setup/doctype/company/charts/hn_cuentas_plantilla.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/hn_cuentas_plantilla.json diff --git a/erpnext/setup/doctype/company/charts/import_from_openerp.py b/erpnext/accounts/doctype/chart_of_accounts/charts/import_from_openerp.py similarity index 100% rename from erpnext/setup/doctype/company/charts/import_from_openerp.py rename to erpnext/accounts/doctype/chart_of_accounts/charts/import_from_openerp.py diff --git a/erpnext/setup/doctype/company/charts/in_indian_chart_template_private.json b/erpnext/accounts/doctype/chart_of_accounts/charts/in_indian_chart_template_private.json similarity index 100% rename from erpnext/setup/doctype/company/charts/in_indian_chart_template_private.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/in_indian_chart_template_private.json diff --git a/erpnext/setup/doctype/company/charts/in_indian_chart_template_public.json b/erpnext/accounts/doctype/chart_of_accounts/charts/in_indian_chart_template_public.json similarity index 100% rename from erpnext/setup/doctype/company/charts/in_indian_chart_template_public.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/in_indian_chart_template_public.json diff --git a/erpnext/setup/doctype/company/charts/it_l10n_it_chart_template_generic.json b/erpnext/accounts/doctype/chart_of_accounts/charts/it_l10n_it_chart_template_generic.json similarity index 100% rename from erpnext/setup/doctype/company/charts/it_l10n_it_chart_template_generic.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/it_l10n_it_chart_template_generic.json diff --git a/erpnext/setup/doctype/company/charts/lu_lu_2011_chart_1.json b/erpnext/accounts/doctype/chart_of_accounts/charts/lu_lu_2011_chart_1.json similarity index 100% rename from erpnext/setup/doctype/company/charts/lu_lu_2011_chart_1.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/lu_lu_2011_chart_1.json diff --git a/erpnext/setup/doctype/company/charts/ma_l10n_kzc_temp_chart.json b/erpnext/accounts/doctype/chart_of_accounts/charts/ma_l10n_kzc_temp_chart.json similarity index 100% rename from erpnext/setup/doctype/company/charts/ma_l10n_kzc_temp_chart.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/ma_l10n_kzc_temp_chart.json diff --git a/erpnext/setup/doctype/company/charts/nl_l10nnl_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/nl_l10nnl_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/nl_l10nnl_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/nl_l10nnl_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/pa_l10npa_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/pa_l10npa_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/pa_l10npa_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/pa_l10npa_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/pe_pe_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/pe_pe_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/pe_pe_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/pe_pe_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/pl_pl_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/pl_pl_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/pl_pl_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/pl_pl_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/pt_pt_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/pt_pt_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/pt_pt_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/pt_pt_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/ro_romania_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/ro_romania_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/ro_romania_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/ro_romania_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/syscohada_syscohada_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/syscohada_syscohada_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/syscohada_syscohada_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/syscohada_syscohada_chart_template.json diff --git a/erpnext/setup/doctype/company/charts/th_chart.json b/erpnext/accounts/doctype/chart_of_accounts/charts/th_chart.json similarity index 100% rename from erpnext/setup/doctype/company/charts/th_chart.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/th_chart.json diff --git a/erpnext/setup/doctype/company/charts/tr_l10ntr_tek_duzen_hesap.json b/erpnext/accounts/doctype/chart_of_accounts/charts/tr_l10ntr_tek_duzen_hesap.json similarity index 100% rename from erpnext/setup/doctype/company/charts/tr_l10ntr_tek_duzen_hesap.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/tr_l10ntr_tek_duzen_hesap.json diff --git a/erpnext/setup/doctype/company/charts/us_account_chart_template_basic.json b/erpnext/accounts/doctype/chart_of_accounts/charts/us_account_chart_template_basic.json similarity index 100% rename from erpnext/setup/doctype/company/charts/us_account_chart_template_basic.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/us_account_chart_template_basic.json diff --git a/erpnext/setup/doctype/company/charts/uy_uy_chart_template.json b/erpnext/accounts/doctype/chart_of_accounts/charts/uy_uy_chart_template.json similarity index 100% rename from erpnext/setup/doctype/company/charts/uy_uy_chart_template.json rename to erpnext/accounts/doctype/chart_of_accounts/charts/uy_uy_chart_template.json