From 4528badfcfd843d5d1a6863e62136bfda80c2413 Mon Sep 17 00:00:00 2001 From: Marica Date: Mon, 9 Mar 2020 18:07:43 +0530 Subject: [PATCH] fix: ModuleNotFoundError on Turkey Company setup (#20853) --- erpnext/regional/turkey/setup.py | 4 ++++ erpnext/setup/doctype/company/company.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 erpnext/regional/turkey/setup.py diff --git a/erpnext/regional/turkey/setup.py b/erpnext/regional/turkey/setup.py new file mode 100644 index 0000000000..ebf3b2bee1 --- /dev/null +++ b/erpnext/regional/turkey/setup.py @@ -0,0 +1,4 @@ +from __future__ import unicode_literals + +def setup(company=None, patch=True): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 6aa2c04671..956deef928 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -424,8 +424,13 @@ def install_country_fixtures(company): company_doc = frappe.get_doc("Company", company) path = frappe.get_app_path('erpnext', 'regional', frappe.scrub(company_doc.country)) if os.path.exists(path.encode("utf-8")): - frappe.get_attr("erpnext.regional.{0}.setup.setup" - .format(frappe.scrub(company_doc.country)))(company_doc, False) + try: + module_name = "erpnext.regional.{0}.setup.setup".format(frappe.scrub(company_doc.country)) + frappe.get_attr(module_name)(company_doc, False) + except Exception as e: + frappe.log_error(str(e), frappe.get_traceback()) + frappe.throw(_("Failed to setup defaults for country {0}. Please contact support@erpnext.com").format(frappe.bold(company_doc.country))) + def update_company_current_month_sales(company): current_month_year = formatdate(today(), "MM-yyyy")