fix: report and notification folder deletion on deletion from ui (#37190)
Co-authored-by: Sagar Vora <16315650+sagarvora@users.noreply.github.com>
This commit is contained in:
parent
9bf9fa6d7b
commit
b7214c6957
2 changed files with 23 additions and 1 deletions
|
|
@ -102,6 +102,12 @@ class Report(Document):
|
|||
frappe.throw(_("You are not allowed to delete Standard Report"))
|
||||
delete_custom_role("report", self.name)
|
||||
|
||||
def after_delete(self):
|
||||
from frappe.modules.export_file import delete_folder
|
||||
|
||||
if not frappe.flags.in_test and frappe.conf.developer_mode:
|
||||
delete_folder(self.module, "Report", self.name)
|
||||
|
||||
def get_permission_log_options(self, event=None):
|
||||
return {"fields": ["roles"]}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from frappe.desk.doctype.notification_log.notification_log import enqueue_create
|
|||
from frappe.integrations.doctype.slack_webhook_url.slack_webhook_url import send_slack_message
|
||||
from frappe.model.document import Document
|
||||
from frappe.modules.utils import export_module_json, get_doc_module
|
||||
from frappe.utils import add_to_date, cast, now_datetime, nowdate, validate_email_address
|
||||
from frappe.utils import add_to_date, cast, cint, now_datetime, nowdate, validate_email_address
|
||||
from frappe.utils.data import evaluate_filters
|
||||
from frappe.utils.jinja import validate_template
|
||||
from frappe.utils.safe_exec import get_safe_globals
|
||||
|
|
@ -721,8 +721,24 @@ def get_context(context):
|
|||
self.message = self.get_template(md_as_html=True)
|
||||
|
||||
def on_trash(self):
|
||||
# Prevent deletion of standard notifications outside developer mode to avoid restoration during migration
|
||||
if (
|
||||
self.is_standard
|
||||
and not frappe.conf.developer_mode
|
||||
and not frappe.flags.in_migrate
|
||||
and not frappe.flags.in_patch
|
||||
):
|
||||
frappe.throw(
|
||||
_("You are not allowed to delete a standard Notification. You can disable it instead.")
|
||||
)
|
||||
clear_notification_cache()
|
||||
|
||||
def after_delete(self):
|
||||
from frappe.modules.export_file import delete_folder
|
||||
|
||||
if not frappe.flags.in_test and frappe.conf.developer_mode:
|
||||
delete_folder(self.module, "Notification", self.name)
|
||||
|
||||
|
||||
def clear_notification_cache():
|
||||
frappe.client_cache.delete_keys("notifications::")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue