Skip to content

Commit 5d97e0d

Browse files
SilvioC2Ctrisdoan
authored andcommitted
[IMP] web_notify: allow passing custom parameters to notifications
1 parent 23470c1 commit 5d97e0d

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

web_notify/models/res_users.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ def notify_success(
4949
sticky=False,
5050
target=None,
5151
action=None,
52+
params=None,
5253
):
5354
title = title or _("Success")
54-
self._notify_channel(SUCCESS, message, title, sticky, target, action)
55+
self._notify_channel(SUCCESS, message, title, sticky, target, action, params)
5556

5657
def notify_danger(
5758
self,
@@ -60,9 +61,10 @@ def notify_danger(
6061
sticky=False,
6162
target=None,
6263
action=None,
64+
params=None,
6365
):
6466
title = title or _("Danger")
65-
self._notify_channel(DANGER, message, title, sticky, target, action)
67+
self._notify_channel(DANGER, message, title, sticky, target, action, params)
6668

6769
def notify_warning(
6870
self,
@@ -71,9 +73,10 @@ def notify_warning(
7173
sticky=False,
7274
target=None,
7375
action=None,
76+
params=None,
7477
):
7578
title = title or _("Warning")
76-
self._notify_channel(WARNING, message, title, sticky, target, action)
79+
self._notify_channel(WARNING, message, title, sticky, target, action, params)
7780

7881
def notify_info(
7982
self,
@@ -82,9 +85,10 @@ def notify_info(
8285
sticky=False,
8386
target=None,
8487
action=None,
88+
params=None,
8589
):
8690
title = title or _("Information")
87-
self._notify_channel(INFO, message, title, sticky, target, action)
91+
self._notify_channel(INFO, message, title, sticky, target, action, params)
8892

8993
def notify_default(
9094
self,
@@ -93,9 +97,10 @@ def notify_default(
9397
sticky=False,
9498
target=None,
9599
action=None,
100+
params=None,
96101
):
97102
title = title or _("Default")
98-
self._notify_channel(DEFAULT, message, title, sticky, target, action)
103+
self._notify_channel(DEFAULT, message, title, sticky, target, action, params)
99104

100105
def _notify_channel(
101106
self,
@@ -105,6 +110,7 @@ def _notify_channel(
105110
sticky=False,
106111
target=None,
107112
action=None,
113+
params=None,
108114
):
109115
if not (self.env.user._is_admin() or self.env.su) and any(
110116
user.id != self.env.uid for user in self
@@ -122,6 +128,7 @@ def _notify_channel(
122128
"title": title,
123129
"sticky": sticky,
124130
"action": action,
131+
"params": dict(params or []),
125132
}
126133

127134
notifications = [[partner, "web.notify", [bus_message]] for partner in target]

web_notify/tests/test_res_users.py

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def test_notify_success(self):
1919
"title": "title",
2020
"sticky": True,
2121
"action": None,
22+
"params": {},
2223
}
2324
self.env.user.notify_success(**test_msg)
2425
news = bus_bus.search(domain) - existing
@@ -36,6 +37,7 @@ def test_notify_danger(self):
3637
"title": "title",
3738
"sticky": True,
3839
"action": None,
40+
"params": {},
3941
}
4042
self.env.user.notify_danger(**test_msg)
4143
news = bus_bus.search(domain) - existing
@@ -53,6 +55,7 @@ def test_notify_warning(self):
5355
"title": "title",
5456
"sticky": True,
5557
"action": None,
58+
"params": {},
5659
}
5760
self.env.user.notify_warning(**test_msg)
5861
news = bus_bus.search(domain) - existing
@@ -70,6 +73,7 @@ def test_notify_info(self):
7073
"title": "title",
7174
"sticky": True,
7275
"action": None,
76+
"params": {},
7377
}
7478
self.env.user.notify_info(**test_msg)
7579
news = bus_bus.search(domain) - existing
@@ -87,6 +91,7 @@ def test_notify_default(self):
8791
"title": "title",
8892
"sticky": True,
8993
"action": None,
94+
"params": {},
9095
}
9196
self.env.user.notify_default(**test_msg)
9297
news = bus_bus.search(domain) - existing

0 commit comments

Comments
 (0)