[hotfix] set_restrict_to_domain_for_module_def patch fixes (#9921)
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 3b4b8af..2f97ccf 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 @@
""" 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 91c9697..90878af 100644
--- a/erpnext/setup/setup_wizard/domainify.py
+++ b/erpnext/setup/setup_wizard/domainify.py
@@ -151,8 +151,14 @@
""" 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