From 3c1a53c32587159aa5341ee6ce2f6c6566411753 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Fri, 16 Jun 2017 17:56:12 +0530 Subject: [PATCH] [minor] use reload_doc instead of reload_doctype --- erpnext/patches/v8_0/create_domain_docs.py | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/erpnext/patches/v8_0/create_domain_docs.py b/erpnext/patches/v8_0/create_domain_docs.py index a6fcb86bf4..2f376db3d7 100644 --- a/erpnext/patches/v8_0/create_domain_docs.py +++ b/erpnext/patches/v8_0/create_domain_docs.py @@ -7,14 +7,13 @@ import erpnext def execute(): """Create domain documents""" - frappe.reload_doctype("Domain") + frappe.reload_doc("core", "doctype", "domain") + frappe.reload_doc("core", "doctype", "domain_settings") + frappe.reload_doc("core", "doctype", "has_domain") for domain in ("Distribution", "Manufacturing", "Retail", "Services", "Education"): - if not frappe.db.exists({'doctype': 'Domain', 'domain': domain}): - doc = frappe.new_doc("Domain") - doc.domain = domain - doc.save() - + if not frappe.db.exists({"doctype": "Domain", "domain": domain}): + create_domain(domain) # set domain in domain settings based on company domain @@ -37,6 +36,17 @@ def execute(): if domain in checked_domains: continue + if not frappe.db.get_value("Domain", domain): + # user added custom domain in companies domain field + create_domain(domain) + row = domain_settings.append("active_domains", dict(domain=domain)) - domain_settings.save(ignore_permissions=True) \ No newline at end of file + domain_settings.save(ignore_permissions=True) + +def create_domain(domain): + # create new domain + + doc = frappe.new_doc("Domain") + doc.domain = domain + doc.db_update() \ No newline at end of file