Merge PR #2949 into 16.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2024-10-09 07:23:08 +00:00
3 changed files with 22 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
{
"pull_requests": {
"1724": "(auto) Nothing to port from PR #1724"
}
}

View File

@@ -49,9 +49,10 @@ class ResUsers(models.Model):
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 @@ class ResUsers(models.Model):
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 @@ class ResUsers(models.Model):
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 @@ class ResUsers(models.Model):
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 @@ class ResUsers(models.Model):
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 @@ class ResUsers(models.Model):
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 @@ class ResUsers(models.Model):
"title": title,
"sticky": sticky,
"action": action,
"params": dict(params or []),
}
notifications = [[partner, "web.notify", [bus_message]] for partner in target]

View File

@@ -19,6 +19,7 @@ class TestResUsers(common.TransactionCase):
"title": "title",
"sticky": True,
"action": None,
"params": {},
}
self.env.user.notify_success(**test_msg)
news = bus_bus.search(domain) - existing
@@ -36,6 +37,7 @@ class TestResUsers(common.TransactionCase):
"title": "title",
"sticky": True,
"action": None,
"params": {},
}
self.env.user.notify_danger(**test_msg)
news = bus_bus.search(domain) - existing
@@ -53,6 +55,7 @@ class TestResUsers(common.TransactionCase):
"title": "title",
"sticky": True,
"action": None,
"params": {},
}
self.env.user.notify_warning(**test_msg)
news = bus_bus.search(domain) - existing
@@ -70,6 +73,7 @@ class TestResUsers(common.TransactionCase):
"title": "title",
"sticky": True,
"action": None,
"params": {},
}
self.env.user.notify_info(**test_msg)
news = bus_bus.search(domain) - existing
@@ -87,6 +91,7 @@ class TestResUsers(common.TransactionCase):
"title": "title",
"sticky": True,
"action": None,
"params": {},
}
self.env.user.notify_default(**test_msg)
news = bus_bus.search(domain) - existing