Browse Source

[hot] revert domain_settings patch

version-14
Rushabh Mehta 7 years ago
parent
commit
effe13925e
3 changed files with 34 additions and 1 deletions
  1. +22
    -0
      frappe/core/doctype/domain/domain.py
  2. +2
    -1
      frappe/patches.txt
  3. +10
    -0
      frappe/patches/v9_1/revert_domain_settings.py

+ 22
- 0
frappe/core/doctype/domain/domain.py View File

@@ -31,6 +31,28 @@ class Domain(Document):
# custom on_setup method
frappe.get_attr(self.data.on_setup)()

def remove_domain(self):
'''Unset domain settings'''
self.setup_data()
for role_name in self.data.restricted_roles:
if frappe.db.exists('Role', role_name):
role = frappe.get_doc('Role', role_name)
role.disabled = 1
role.save()

if self.data.custom_fields:
for doctype in self.data.custom_fields:
custom_fields = self.data.custom_fields[doctype]

# custom_fields can be a list or dict
if isinstance(custom_fields, dict):
custom_fields = [custom_fields]

for custom_field_detail in custom_fields:
custom_field = frappe.get_doc('Custom Field',
dict(dt=doctype, fieldname=custom_field_detail.get('fieldname')))
custom_field.delete()


def setup_roles(self):
'''Enable roles that are restricted to this domain'''


+ 2
- 1
frappe/patches.txt View File

@@ -196,4 +196,5 @@ frappe.patches.v8_5.patch_event_colors
frappe.patches.v8_10.delete_static_web_page_from_global_search
frappe.patches.v8_x.add_bgn_xaf_xof_currencies
frappe.patches.v9_1.add_sms_sender_name_as_parameters
frappe.patches.v9_1.resave_domain_settings
frappe.patches.v9_1.resave_domain_settings
frappe.patches.v9_1.revert_domain_settings

+ 10
- 0
frappe/patches/v9_1/revert_domain_settings.py View File

@@ -0,0 +1,10 @@
import frappe

def execute():
domain_settings = frappe.get_doc('Domain Settings')
active_domains = [d.domain for d in domain_settings.active_domains]

for domain_name in ('Education', 'Healthcare', 'Hospitality'):
if domain_name not in active_domains:
domain = frappe.get_doc('Domain', domain_name)
domain.remove_domain()

Loading…
Cancel
Save