mirror of
https://github.com/frappe/erpnext.git
synced 2026-07-20 11:22:28 +00:00
feat(crm_settings): auto-update crm sync settings on frappe crm install and uninstall
(cherry picked from commit c86aa2d6fe)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
|
||||
import click
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
@@ -188,3 +189,25 @@ def validate_frappe_crm_sync():
|
||||
|
||||
def is_crm_installed():
|
||||
return "crm" in frappe.get_installed_apps()
|
||||
|
||||
|
||||
def remove_allowed_users_on_crm_install():
|
||||
CRMSettings = frappe.get_single("CRM Settings")
|
||||
|
||||
if not CRMSettings.enable_frappe_crm_data_synchronization:
|
||||
return
|
||||
|
||||
CRMSettings.allowed_users = []
|
||||
CRMSettings.save()
|
||||
click.secho("Removed Allowed Users from CRM Settings.")
|
||||
|
||||
|
||||
def disable_frappe_crm_data_synchronization_on_crm_uninstall():
|
||||
CRMSettings = frappe.get_single("CRM Settings")
|
||||
|
||||
if not CRMSettings.enable_frappe_crm_data_synchronization:
|
||||
return
|
||||
|
||||
CRMSettings.enable_frappe_crm_data_synchronization = 0
|
||||
CRMSettings.save()
|
||||
click.secho("Enable Frappe CRM Data Synchronization on CRM Settings has been disabled.")
|
||||
|
||||
@@ -65,6 +65,9 @@ setup_wizard_stages = "erpnext.setup.setup_wizard.setup_wizard.get_setup_stages"
|
||||
|
||||
after_install = "erpnext.setup.install.after_install"
|
||||
|
||||
after_app_install = "erpnext.setup.install.after_app_install"
|
||||
after_app_uninstall = "erpnext.setup.install.after_app_uninstall"
|
||||
|
||||
boot_session = "erpnext.startup.boot.boot_session"
|
||||
notification_config = "erpnext.startup.notifications.get_notification_config"
|
||||
get_help_messages = "erpnext.utilities.activation.get_help_messages"
|
||||
|
||||
@@ -432,3 +432,19 @@ DEFAULT_ROLE_PROFILES = {
|
||||
"Purchase Manager",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def after_app_install(app_name=None):
|
||||
if app_name == "crm":
|
||||
from erpnext.crm.frappe_crm_api import remove_allowed_users_on_crm_install
|
||||
|
||||
remove_allowed_users_on_crm_install()
|
||||
|
||||
|
||||
def after_app_uninstall(app_name=None):
|
||||
if app_name == "crm":
|
||||
from erpnext.crm.frappe_crm_api import disable_frappe_crm_data_synchronization_on_crm_uninstall
|
||||
|
||||
disable_frappe_crm_data_synchronization_on_crm_uninstall()
|
||||
|
||||
frappe.db.commit() # nosemgrep
|
||||
|
||||
Reference in New Issue
Block a user