diff --git a/frappe/core/doctype/report/report.py b/frappe/core/doctype/report/report.py index 19be3fe1a4..6d890a6736 100644 --- a/frappe/core/doctype/report/report.py +++ b/frappe/core/doctype/report/report.py @@ -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"]} diff --git a/frappe/email/doctype/notification/notification.py b/frappe/email/doctype/notification/notification.py index 875796c395..04fc726272 100644 --- a/frappe/email/doctype/notification/notification.py +++ b/frappe/email/doctype/notification/notification.py @@ -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::")