[minor] fixes for chart_of_accounts_builder app
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 bfb5240..e1f9f1c 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
@@ -82,24 +82,26 @@
def _get_chart_name(content):
if content:
content = json.loads(content)
- if content and content.get("is_active", "No") == "Yes" and content.get("disabled", "No") == "No":
+
+ if frappe.local.flags.allow_unverified_charts:
+ charts.append(content["name"])
+
+ elif content and content.get("is_active", "No") == "Yes" and content.get("disabled", "No") == "No":
charts.append(content["name"])
country_code = frappe.db.get_value("Country", country, "code")
if country_code:
- path = os.path.join(os.path.dirname(__file__), "verified")
- for fname in os.listdir(path):
- if fname.startswith(country_code) and fname.endswith(".json"):
- with open(os.path.join(path, fname), "r") as f:
- _get_chart_name(f.read())
+ folders = ("verified",)
+ if frappe.local.flags.allow_unverified_charts:
+ folders = ("verified", "unverified")
- # countries_use_OHADA_system = ["Benin", "Burkina Faso", "Cameroon", "Central African Republic", "Comoros",
- # "Congo", "Ivory Coast", "Gabon", "Guinea", "Guinea Bissau", "Equatorial Guinea", "Mali", "Niger",
- # "Replica of Democratic Congo", "Senegal", "Chad", "Togo"]
- #
- # if country in countries_use_OHADA_system:
- # with open(os.path.join(os.path.dirname(__file__), "syscohada_syscohada_chart_template.json"), "r") as f:
- # _get_chart_name(f.read())
+ for folder in folders:
+ path = os.path.join(os.path.dirname(__file__), folder)
+
+ for fname in os.listdir(path):
+ if fname.startswith(country_code) and fname.endswith(".json"):
+ with open(os.path.join(path, fname), "r") as f:
+ _get_chart_name(f.read())
if len(charts) != 1:
charts.append("Standard")
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index d337805..120106a 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -216,13 +216,15 @@
frappe.db.sql("""delete from `tabItem Reorder` where warehouse in (%s)"""
% ', '.join(['%s']*len(warehouses)), tuple(warehouses))
- for f in ["income_account", "expense_account"]:
- frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
- % (f, f, ', '.join(['%s']*len(accounts))), tuple(accounts))
+ if accounts:
+ for f in ["income_account", "expense_account"]:
+ frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
+ % (f, f, ', '.join(['%s']*len(accounts))), tuple(accounts))
- for f in ["selling_cost_center", "buying_cost_center"]:
- frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
- % (f, f, ', '.join(['%s']*len(cost_centers))), tuple(cost_centers))
+ if cost_centers:
+ for f in ["selling_cost_center", "buying_cost_center"]:
+ frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
+ % (f, f, ', '.join(['%s']*len(cost_centers))), tuple(cost_centers))
# reset default company
frappe.db.sql("""update `tabSingles` set value=""