[minor] chart_of_accounts.py for python3

This commit is contained in:
Rushabh Mehta 2018-05-23 16:14:18 +05:30
parent f7414519bb
commit 315dbd2ed1

View File

@ -44,9 +44,9 @@ def create_charts(company, chart_template=None, existing_company=None):
if root_account or frappe.local.flags.allow_unverified_charts:
account.flags.ignore_mandatory = True
account.flags.ignore_permissions = True
account.insert()
accounts.append(account_name_in_db)
@ -82,7 +82,7 @@ def get_chart(chart_template, existing_company=None):
chart = {}
if existing_company:
return get_account_tree_from_existing_company(existing_company)
elif chart_template == "Standard":
from erpnext.accounts.doctype.account.chart_of_accounts.verified import standard_chart_of_accounts
return standard_chart_of_accounts.get()
@ -123,6 +123,8 @@ def get_charts_for_country(country, with_standard=False):
for folder in folders:
path = os.path.join(os.path.dirname(__file__), folder)
if not os.path.exists(path):
continue
for fname in os.listdir(path):
fname = frappe.as_unicode(fname)
@ -130,6 +132,7 @@ def get_charts_for_country(country, with_standard=False):
with open(os.path.join(path, fname), "r") as f:
_get_chart_name(f.read())
# if more than one charts, returned then add the standard
if len(charts) != 1 or with_standard:
charts += ["Standard", "Standard with Numbers"]
@ -154,7 +157,7 @@ def build_account_tree(tree, parent, all_accounts):
# find children
parent_account = parent.name if parent else ""
children = [acc for acc in all_accounts if cstr(acc.parent_account) == parent_account]
# if no children, but a group account
if not children and parent.is_group:
tree["is_group"] = 1
@ -164,7 +167,7 @@ def build_account_tree(tree, parent, all_accounts):
for child in children:
# start new subtree
tree[child.account_name] = {}
# assign account_type and root_type
if child.account_number:
tree[child.account_name]["account_number"] = child.account_number
@ -174,7 +177,7 @@ def build_account_tree(tree, parent, all_accounts):
tree[child.account_name]["tax_rate"] = child.tax_rate
if not parent:
tree[child.account_name]["root_type"] = child.root_type
# call recursively to build a subtree for current account
build_account_tree(tree[child.account_name], child, all_accounts)
@ -182,7 +185,7 @@ def build_account_tree(tree, parent, all_accounts):
def validate_bank_account(coa, bank_account):
accounts = []
chart = get_chart(coa)
if chart:
def _get_account_names(account_master):
for account_name, child in iteritems(account_master):