Skip to content

Commit

Permalink
Merge pull request #1194 from OCA/15.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/web (15.0)
  • Loading branch information
bt-admin authored Jan 7, 2024
2 parents 236e79c + 95b9199 commit 95ba535
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ addon | version | maintainers | summary
[web_m2x_options](web_m2x_options/) | 15.0.1.1.0 | | web_m2x_options
[web_m2x_options_manager](web_m2x_options_manager/) | 15.0.1.0.0 | | Adds an interface to manage the "Create" and "Create and Edit" options for specific models and fields.
[web_no_bubble](web_no_bubble/) | 15.0.1.0.0 | | Remove the bubbles from the web interface
[web_notify](web_notify/) | 15.0.1.0.1 | | Send notification messages to user
[web_notify](web_notify/) | 15.0.1.1.0 | | Send notification messages to user
[web_pivot_computed_measure](web_pivot_computed_measure/) | 15.0.1.0.3 | | Web Pivot Computed Measure
[web_pwa_oca](web_pwa_oca/) | 15.0.1.0.0 | [![eLBati](https://github.com/eLBati.png?size=30px)](https://github.com/eLBati) | Make Odoo a PWA
[web_refresher](web_refresher/) | 15.0.2.0.0 | | Web Refresher
Expand Down
2 changes: 1 addition & 1 deletion web_notify/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Web Notify
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4f6423c5c49d113fe994d411d2b055ae2838325cbf03640536284d4f12738826
!! source digest: sha256:5939f6a4cc411dab0ff9e45a43676cbcf8ecafcd7718961aee386fefc24e189d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand Down
2 changes: 1 addition & 1 deletion web_notify/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "Web Notify",
"summary": """
Send notification messages to user""",
"version": "15.0.1.0.1",
"version": "15.0.1.1.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV," "AdaptiveCity," "Odoo Community Association (OCA)",
"development_status": "Production/Stable",
Expand Down
47 changes: 37 additions & 10 deletions web_notify/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,59 @@ def _compute_channel_names(self):
notify_default_channel_name = fields.Char(compute="_compute_channel_names")

def notify_success(
self, message="Default message", title=None, sticky=False, target=None
self,
message="Default message",
title=None,
sticky=False,
target=None,
html=False,
):
title = title or _("Success")
self._notify_channel(SUCCESS, message, title, sticky, target)
self._notify_channel(SUCCESS, message, title, sticky, target, html)

def notify_danger(
self, message="Default message", title=None, sticky=False, target=None
self,
message="Default message",
title=None,
sticky=False,
target=None,
html=False,
):
title = title or _("Danger")
self._notify_channel(DANGER, message, title, sticky, target)
self._notify_channel(DANGER, message, title, sticky, target, html)

def notify_warning(
self, message="Default message", title=None, sticky=False, target=None
self,
message="Default message",
title=None,
sticky=False,
target=None,
html=False,
):
title = title or _("Warning")
self._notify_channel(WARNING, message, title, sticky, target)
self._notify_channel(WARNING, message, title, sticky, target, html)

def notify_info(
self, message="Default message", title=None, sticky=False, target=None
self,
message="Default message",
title=None,
sticky=False,
target=None,
html=False,
):
title = title or _("Information")
self._notify_channel(INFO, message, title, sticky, target)
self._notify_channel(INFO, message, title, sticky, target, html)

def notify_default(
self, message="Default message", title=None, sticky=False, target=None
self,
message="Default message",
title=None,
sticky=False,
target=None,
html=False,
):
title = title or _("Default")
self._notify_channel(DEFAULT, message, title, sticky, target)
self._notify_channel(DEFAULT, message, title, sticky, target, html)

def _notify_channel(
self,
Expand All @@ -78,6 +103,7 @@ def _notify_channel(
title=None,
sticky=False,
target=None,
html=False,
):
if not (self.env.user._is_admin() or self.env.su) and any(
user.id != self.env.uid for user in self
Expand All @@ -92,6 +118,7 @@ def _notify_channel(
"message": message,
"title": title,
"sticky": sticky,
"html": html,
}

notifications = [[partner, "web.notify", [bus_message]] for partner in target]
Expand Down
3 changes: 1 addition & 2 deletions web_notify/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -367,7 +366,7 @@ <h1 class="title">Web Notify</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4f6423c5c49d113fe994d411d2b055ae2838325cbf03640536284d4f12738826
!! source digest: sha256:5939f6a4cc411dab0ff9e45a43676cbcf8ecafcd7718961aee386fefc24e189d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/15.0/web_notify"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_notify"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Send instant notification messages to the user in live.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const webNotificationService = {
type: notif.type,
sticky: notif.sticky,
className: notif.className,
messageIsHtml: notif.html,
});
});
});
Expand Down
35 changes: 30 additions & 5 deletions web_notify/tests/test_res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ def test_notify_success(self):
bus_bus = self.env["bus.bus"]
domain = [("channel", "=", self.env.user.notify_success_channel_name)]
existing = bus_bus.search(domain)
test_msg = {"message": "message", "title": "title", "sticky": True}
test_msg = {
"message": "message",
"title": "title",
"sticky": True,
"html": False,
}
self.env.user.notify_success(**test_msg)
news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news))
Expand All @@ -26,7 +31,12 @@ def test_notify_danger(self):
bus_bus = self.env["bus.bus"]
domain = [("channel", "=", self.env.user.notify_danger_channel_name)]
existing = bus_bus.search(domain)
test_msg = {"message": "message", "title": "title", "sticky": True}
test_msg = {
"message": "message",
"title": "title",
"sticky": True,
"html": False,
}
self.env.user.notify_danger(**test_msg)
news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news))
Expand All @@ -38,7 +48,12 @@ def test_notify_warning(self):
bus_bus = self.env["bus.bus"]
domain = [("channel", "=", self.env.user.notify_warning_channel_name)]
existing = bus_bus.search(domain)
test_msg = {"message": "message", "title": "title", "sticky": True}
test_msg = {
"message": "message",
"title": "title",
"sticky": True,
"html": False,
}
self.env.user.notify_warning(**test_msg)
news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news))
Expand All @@ -50,7 +65,12 @@ def test_notify_info(self):
bus_bus = self.env["bus.bus"]
domain = [("channel", "=", self.env.user.notify_info_channel_name)]
existing = bus_bus.search(domain)
test_msg = {"message": "message", "title": "title", "sticky": True}
test_msg = {
"message": "message",
"title": "title",
"sticky": True,
"html": False,
}
self.env.user.notify_info(**test_msg)
news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news))
Expand All @@ -62,7 +82,12 @@ def test_notify_default(self):
bus_bus = self.env["bus.bus"]
domain = [("channel", "=", self.env.user.notify_default_channel_name)]
existing = bus_bus.search(domain)
test_msg = {"message": "message", "title": "title", "sticky": True}
test_msg = {
"message": "message",
"title": "title",
"sticky": True,
"html": False,
}
self.env.user.notify_default(**test_msg)
news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news))
Expand Down

0 comments on commit 95ba535

Please sign in to comment.