From 5e75e3ba030ef1100338bd85f587a6bd306d35db Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Tue, 18 Jul 2017 15:09:30 +0530 Subject: [PATCH] [hotfix] set_restrict_to_domain_for_module_def patch fixes (#9921) --- .../v8_3/set_restrict_to_domain_for_module_def.py | 3 ++- erpnext/setup/setup_wizard/domainify.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v8_3/set_restrict_to_domain_for_module_def.py b/erpnext/patches/v8_3/set_restrict_to_domain_for_module_def.py index 3b4b8af89c..2f97ccfe02 100644 --- a/erpnext/patches/v8_3/set_restrict_to_domain_for_module_def.py +++ b/erpnext/patches/v8_3/set_restrict_to_domain_for_module_def.py @@ -10,4 +10,5 @@ def execute(): """ set the restrict to domain in module def """ frappe.reload_doc("core", "doctype", "module_def") - update_module_def_restrict_to_domain() \ No newline at end of file + if frappe.db.get_single_value('System Settings', 'setup_complete'): + update_module_def_restrict_to_domain() \ No newline at end of file diff --git a/erpnext/setup/setup_wizard/domainify.py b/erpnext/setup/setup_wizard/domainify.py index 91c9697309..90878af75c 100644 --- a/erpnext/setup/setup_wizard/domainify.py +++ b/erpnext/setup/setup_wizard/domainify.py @@ -151,8 +151,14 @@ def update_module_def_restrict_to_domain(): """ set the restrict to domain for the module def """ module_def_restrict_to_domain_mapper = { - "Schools": _('Education') + "Schools": 'Education' } + lang = frappe.db.get_single_value("System Settings", "language") or "en" for module, domain in module_def_restrict_to_domain_mapper.iteritems(): - frappe.set_value("Module Def", module, "restrict_to_domain", domain) + if frappe.db.exists("Domain", _(domain, lang)): + frappe.set_value("Module Def", module, "restrict_to_domain", _(domain, lang)) + elif frappe.db.exists("Domain", domain): + frappe.set_value("Module Def", module, "restrict_to_domain", domain) + else: + pass