diff --git a/frappe/desk/doctype/notification_log/notification_log.py b/frappe/desk/doctype/notification_log/notification_log.py index b46795dd8a..4d82932555 100644 --- a/frappe/desk/doctype/notification_log/notification_log.py +++ b/frappe/desk/doctype/notification_log/notification_log.py @@ -20,6 +20,14 @@ class NotificationLog(Document): except frappe.OutgoingEmailError: self.log_error(_("Failed to send notification email")) + @staticmethod + def clear_old_logs(days=180): + from frappe.query_builder import Interval + from frappe.query_builder.functions import Now + + table = frappe.qb.DocType("Notification Log") + frappe.db.delete(table, filters=(table.modified < (Now() - Interval(days=days)))) + def get_permission_query_conditions(for_user): if not for_user: diff --git a/frappe/desk/doctype/notification_log/notification_log_list.js b/frappe/desk/doctype/notification_log/notification_log_list.js new file mode 100644 index 0000000000..150ffabfa7 --- /dev/null +++ b/frappe/desk/doctype/notification_log/notification_log_list.js @@ -0,0 +1,7 @@ +frappe.listview_settings["Notification Log"] = { + onload: function (listview) { + frappe.require("logtypes.bundle.js", () => { + frappe.utils.logtypes.show_log_retention_message(cur_list.doctype); + }); + }, +};