Merge branch 'pratu16x7-domainify' into domainify (#9324)
* bootstrap domains and set active_domain on setup * [minor] Patch for domain docs * [minor] * Update create_domain_docs.py
This commit is contained in:
committed by
Rushabh Mehta
parent
2510d1c86a
commit
dd986f659e
41
erpnext/patches/v8_0/create_domain_docs.py
Normal file
41
erpnext/patches/v8_0/create_domain_docs.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import erpnext
|
||||
|
||||
def execute():
|
||||
"""Create domain documents"""
|
||||
|
||||
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()
|
||||
|
||||
|
||||
# set domain in domain settings based on company domain
|
||||
|
||||
domains = []
|
||||
condition = ""
|
||||
company = erpnext.get_default_company()
|
||||
if company:
|
||||
condition = " where name='{0}'".format(company)
|
||||
|
||||
domains = frappe.db.sql_list("select distinct domain from `tabCompany` {0}".format(condition))
|
||||
|
||||
if not domains:
|
||||
return
|
||||
|
||||
domain_settings = frappe.get_doc("Domain Settings", "Domain Settings")
|
||||
checked_domains = [row.domain for row in domain_settings.active_domains]
|
||||
|
||||
for domain in domains:
|
||||
# check and ignore if the domains is already checked in domain settings
|
||||
if domain in checked_domains:
|
||||
continue
|
||||
|
||||
row = domain_settings.append("active_domains", dict(domain=args.domain))
|
||||
|
||||
domain_settings.save(ignore_permissions=True)
|
||||
Reference in New Issue
Block a user