diff --git a/trytond/trytond/res/notification.py b/trytond/trytond/res/notification.py index 3f072a68b4..9492c7cabc 100644 --- a/trytond/trytond/res/notification.py +++ b/trytond/trytond/res/notification.py @@ -4,7 +4,6 @@ import json from collections import defaultdict -from sql import Literal from sql.aggregate import Count from trytond.bus import Bus @@ -149,7 +148,7 @@ class Notification( notification = cls.__table__() cursor = Transaction().connection.cursor() cursor.execute(*notification.select( - Count(Literal('*')), + Count(), where=((notification.user == Transaction().user) & notification.unread))) return cursor.fetchone()[0] diff --git a/trytond/trytond/tests/test_chat.py b/trytond/trytond/tests/test_chat.py index ece37c9106..25f34b6c28 100644 --- a/trytond/trytond/tests/test_chat.py +++ b/trytond/trytond/tests/test_chat.py @@ -49,6 +49,7 @@ class NotificationTestCase(TestCase): self.assertEqual(message.audience, 'public') self.assertEqual(message.content, "Chat Message: Bar") with Transaction().set_user(alice.id): + self.assertEqual(Notification.get_count(), 1) notification, = Notification.get() self.assertEqual(notification, { 'id': notification['id'],