Publish a message when notifications are silenced

#14698
This commit is contained in:
Cédric Krier committed 2026-03-20 18:42:55 +01:00
1 parent 72e6f17b81
commit b9b81dbc68
2 files changed
+14

No files matched your search

+4
View File
@@ -28,5 +28,9 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="msg_user_password">
<field name="text">Password for %(login)s</field>
</record>
<record model="ir.message" id="msg_notification_silenced">
<field name="text">%(number)s notification silenced.</field>
<field name="text_plural">%(number)s notifications silenced.</field>
</record>
</data>
</tryton>
+10
View File
@@ -9,6 +9,7 @@ from functools import partial
from sql.aggregate import Count
from trytond.bus import Bus
from trytond.i18n import ngettext
from trytond.ir.ui.menu import CLIENT_ICONS
from trytond.model import Index, ModelSQL, ModelView, fields
from trytond.pool import Pool
@@ -82,6 +83,10 @@ class Notification(
@classmethod
def create(cls, vlist):
pool = Pool()
Lang = pool.get('ir.lang')
lang = Lang.get()
notifications = super().create(vlist)
notifications_by_user = defaultdict(list)
@@ -102,6 +107,11 @@ class Notification(
messages = [
'\n'.join(map(shorten, filter(None, (n.label, n.description))))
for n in user_notifications[:4]]
if len(user_notifications) > 4:
n = len(user_notifications) - 4
messages.append(ngettext(
'res.msg_notification_silenced', n,
number=lang.format_number(n)))
Bus.publish(
f'notification:{user}', {
'type': 'user-notification',