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:
Makarand Bauskar 2017-06-16 13:02:45 +05:30 committed by Rushabh Mehta
parent 2510d1c86a
commit dd986f659e
5 changed files with 58 additions and 4 deletions

View File

@ -403,3 +403,4 @@ erpnext.patches.v8_0.rename_items_in_status_field_of_material_request
erpnext.patches.v8_0.delete_bin_indexes
erpnext.patches.v8_0.move_account_head_from_account_to_warehouse_for_inventory
erpnext.patches.v8_0.change_in_words_varchar_length
erpnext.patches.v8_0.create_domain_docs

View 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)

View File

@ -105,8 +105,9 @@ def setup_roles(data):
if data.allow_roles:
# remove all roles other than allowed roles
active_domains = frappe.get_active_domains()
data.allow_roles += ['Administrator', 'Guest', 'System Manager', 'All']
for role in frappe.get_all('Role'):
for role in frappe.get_all('Role', filters = {"restrict_to_domain": ("not in", active_domains)}):
if not (role.name in data.allow_roles):
remove_role(role.name)

View File

@ -13,6 +13,13 @@ default_lead_sources = ["Existing Customer", "Reference", "Advertisement",
def install(country=None):
records = [
# domains
{ 'doctype': 'Domain', 'domain': _('Distribution')},
{ 'doctype': 'Domain', 'domain': _('Manufacturing')},
{ 'doctype': 'Domain', 'domain': _('Retail')},
{ 'doctype': 'Domain', 'domain': _('Services')},
{ 'doctype': 'Domain', 'domain': _('Education')},
# address template
{'doctype':"Address Template", "country": country},

View File

@ -198,6 +198,10 @@ def set_defaults(args):
hr_settings.emp_created_by = "Naming Series"
hr_settings.save()
domain_settings = frappe.get_doc("Domain Settings")
domain_settings.append('active_domain', dict(domain=args.domain))
domain_settings.save()
def create_feed_and_todo():
"""update Activity feed and create todo for creation of item, customer, vendor"""
add_info_comment(**{