From d196dfeac437563a886feaaa2d1849511dfa009e Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 25 Oct 2023 11:22:05 +0530 Subject: [PATCH] fix: ignore perm while updating notification settings If you can update user, do you should be able to update notif settings. --- frappe/core/doctype/user/user.py | 2 +- .../doctype/notification_settings/notification_settings.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frappe/core/doctype/user/user.py b/frappe/core/doctype/user/user.py index f22c62050e..cdb3e394ee 100644 --- a/frappe/core/doctype/user/user.py +++ b/frappe/core/doctype/user/user.py @@ -248,7 +248,7 @@ class User(Document): frappe.local.login_manager.logout(user=self.name) # toggle notifications based on the user's status - toggle_notifications(self.name, enable=cint(self.enabled)) + toggle_notifications(self.name, enable=cint(self.enabled), ignore_permissions=True) def add_system_manager_role(self): if self.is_system_manager_disabled(): diff --git a/frappe/desk/doctype/notification_settings/notification_settings.py b/frappe/desk/doctype/notification_settings/notification_settings.py index 45b946ec28..431c94f53d 100644 --- a/frappe/desk/doctype/notification_settings/notification_settings.py +++ b/frappe/desk/doctype/notification_settings/notification_settings.py @@ -70,7 +70,7 @@ def create_notification_settings(user): _doc.insert(ignore_permissions=True) -def toggle_notifications(user: str, enable: bool = False): +def toggle_notifications(user: str, enable: bool = False, ignore_permissions=False): try: settings = frappe.get_doc("Notification Settings", user) except frappe.DoesNotExistError: @@ -79,7 +79,7 @@ def toggle_notifications(user: str, enable: bool = False): if settings.enabled != enable: settings.enabled = enable - settings.save() + settings.save(ignore_permissions=ignore_permissions) @frappe.whitelist()