diff --git a/frappe/core/doctype/user/user.py b/frappe/core/doctype/user/user.py index ba269a61be..7de2bb20e5 100644 --- a/frappe/core/doctype/user/user.py +++ b/frappe/core/doctype/user/user.py @@ -48,8 +48,7 @@ class User(Document): throttle_user_creation() def after_insert(self): - if not frappe.db.exists("Notification Settings", self.name): - create_notification_settings(self.name) + create_notification_settings(self.name) def validate(self): self.check_demo() @@ -371,6 +370,7 @@ class User(Document): if frappe.db.exists("Notification Settings", old_name): frappe.rename_doc("Notification Settings", old_name, new_name, force=True) + # set email frappe.db.sql("""UPDATE `tabUser` SET email = %s diff --git a/frappe/desk/doctype/notification_log/notification_log.py b/frappe/desk/doctype/notification_log/notification_log.py index 17c4d3ba4b..c6d4218773 100644 --- a/frappe/desk/doctype/notification_log/notification_log.py +++ b/frappe/desk/doctype/notification_log/notification_log.py @@ -120,6 +120,7 @@ def mark_all_as_read(): filters = {'name': ['in', unread_docnames]} frappe.db.set_value('Notification Log', filters, 'read', 1, update_modified=False) + @frappe.whitelist() def mark_as_read(docname): if docname: diff --git a/frappe/desk/doctype/notification_settings/notification_settings.py b/frappe/desk/doctype/notification_settings/notification_settings.py index 8cd7d93391..295b4c8afd 100644 --- a/frappe/desk/doctype/notification_settings/notification_settings.py +++ b/frappe/desk/doctype/notification_settings/notification_settings.py @@ -32,10 +32,11 @@ def is_email_notifications_enabled_for_type(user, notification_type): return enabled def create_notification_settings(user): - _doc = frappe.new_doc('Notification Settings') - _doc.name = user - _doc.insert(ignore_permissions=True) - frappe.db.commit() + if not frappe.db.exists("Notification Settings", user): + _doc = frappe.new_doc('Notification Settings') + _doc.name = user + _doc.insert(ignore_permissions=True) + frappe.db.commit() @frappe.whitelist() diff --git a/frappe/patches/v12_0/create_notification_settings_for_user.py b/frappe/patches/v12_0/create_notification_settings_for_user.py index ad12390c4f..170931bdf3 100644 --- a/frappe/patches/v12_0/create_notification_settings_for_user.py +++ b/frappe/patches/v12_0/create_notification_settings_for_user.py @@ -7,7 +7,4 @@ def execute(): users = frappe.db.get_all('User', fields=['name']) for user in users: - if frappe.db.exists("Notification Settings", user.name): - continue - create_notification_settings(user.name) \ No newline at end of file