From 5d97e0d1a274689c98ca49f17b11364e9b7b9c71 Mon Sep 17 00:00:00 2001 From: SilvioC2C Date: Fri, 16 Feb 2024 12:58:43 +0100 Subject: [PATCH 1/2] [IMP] web_notify: allow passing custom parameters to notifications --- web_notify/models/res_users.py | 17 ++++++++++++----- web_notify/tests/test_res_users.py | 5 +++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/web_notify/models/res_users.py b/web_notify/models/res_users.py index 1bea86266289..11339fd6f611 100644 --- a/web_notify/models/res_users.py +++ b/web_notify/models/res_users.py @@ -49,9 +49,10 @@ def notify_success( sticky=False, target=None, action=None, + params=None, ): title = title or _("Success") - self._notify_channel(SUCCESS, message, title, sticky, target, action) + self._notify_channel(SUCCESS, message, title, sticky, target, action, params) def notify_danger( self, @@ -60,9 +61,10 @@ def notify_danger( sticky=False, target=None, action=None, + params=None, ): title = title or _("Danger") - self._notify_channel(DANGER, message, title, sticky, target, action) + self._notify_channel(DANGER, message, title, sticky, target, action, params) def notify_warning( self, @@ -71,9 +73,10 @@ def notify_warning( sticky=False, target=None, action=None, + params=None, ): title = title or _("Warning") - self._notify_channel(WARNING, message, title, sticky, target, action) + self._notify_channel(WARNING, message, title, sticky, target, action, params) def notify_info( self, @@ -82,9 +85,10 @@ def notify_info( sticky=False, target=None, action=None, + params=None, ): title = title or _("Information") - self._notify_channel(INFO, message, title, sticky, target, action) + self._notify_channel(INFO, message, title, sticky, target, action, params) def notify_default( self, @@ -93,9 +97,10 @@ def notify_default( sticky=False, target=None, action=None, + params=None, ): title = title or _("Default") - self._notify_channel(DEFAULT, message, title, sticky, target, action) + self._notify_channel(DEFAULT, message, title, sticky, target, action, params) def _notify_channel( self, @@ -105,6 +110,7 @@ def _notify_channel( sticky=False, target=None, action=None, + params=None, ): if not (self.env.user._is_admin() or self.env.su) and any( user.id != self.env.uid for user in self @@ -122,6 +128,7 @@ def _notify_channel( "title": title, "sticky": sticky, "action": action, + "params": dict(params or []), } notifications = [[partner, "web.notify", [bus_message]] for partner in target] diff --git a/web_notify/tests/test_res_users.py b/web_notify/tests/test_res_users.py index 76fedc1182a9..f05e6709a765 100644 --- a/web_notify/tests/test_res_users.py +++ b/web_notify/tests/test_res_users.py @@ -19,6 +19,7 @@ def test_notify_success(self): "title": "title", "sticky": True, "action": None, + "params": {}, } self.env.user.notify_success(**test_msg) news = bus_bus.search(domain) - existing @@ -36,6 +37,7 @@ def test_notify_danger(self): "title": "title", "sticky": True, "action": None, + "params": {}, } self.env.user.notify_danger(**test_msg) news = bus_bus.search(domain) - existing @@ -53,6 +55,7 @@ def test_notify_warning(self): "title": "title", "sticky": True, "action": None, + "params": {}, } self.env.user.notify_warning(**test_msg) news = bus_bus.search(domain) - existing @@ -70,6 +73,7 @@ def test_notify_info(self): "title": "title", "sticky": True, "action": None, + "params": {}, } self.env.user.notify_info(**test_msg) news = bus_bus.search(domain) - existing @@ -87,6 +91,7 @@ def test_notify_default(self): "title": "title", "sticky": True, "action": None, + "params": {}, } self.env.user.notify_default(**test_msg) news = bus_bus.search(domain) - existing From fd3c2c67c7465e8992ba12f3ad6375842198d010 Mon Sep 17 00:00:00 2001 From: trisdoan Date: Mon, 7 Oct 2024 14:32:23 +0700 Subject: [PATCH 2/2] oca-port: blacklist PR(s) 1724 for web_notify --- .oca/oca-port/blacklist/web_notify.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .oca/oca-port/blacklist/web_notify.json diff --git a/.oca/oca-port/blacklist/web_notify.json b/.oca/oca-port/blacklist/web_notify.json new file mode 100644 index 000000000000..b69cba9f0315 --- /dev/null +++ b/.oca/oca-port/blacklist/web_notify.json @@ -0,0 +1,5 @@ +{ + "pull_requests": { + "1724": "(auto) Nothing to port from PR #1724" + } +}