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:
Priyal208 2026-02-23 14:15:43 +05:30 committed by GitHub
parent 9bf9fa6d7b
commit b7214c6957
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View file

@ -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"]}

View file

@ -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::")