charts of account doctype added and imported charts json from openerp

This commit is contained in:
Nabin Hait 2014-03-06 18:19:06 +05:30
parent b77773ca07
commit d89f3403ac
38 changed files with 112 additions and 0 deletions

View File

@ -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)

View File

@ -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"
}
]