diff --git a/web_notify/README.rst b/web_notify/README.rst
index c3fb682a4..eb657c0b9 100644
--- a/web_notify/README.rst
+++ b/web_notify/README.rst
@@ -7,7 +7,7 @@ Web Notify
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! source digest: sha256:2ea37128bc36b2b82559d0718dff171b9d2e3dcde596a8c8750d6926821862fc
+ !! source digest: sha256:387191333e79a8835b7ba7ad61d692b8940bf5bef0ef2a0f9696248c74723ed4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
@@ -91,28 +91,28 @@ The notifications can bring interactivity with some buttons.
The reload button is activated when sending the notification with:
-
-The action can be used using the ``action`` keyword:
+The action can be used using the ``action`` keyword and we can choose which name to
+give to our button with the ``button_name`` key in the action context `params` key:
.. code-block:: python
action = self.env["ir.actions.act_window"]._for_xml_id('sale.action_orders')
action.update({
- 'res_id': self.id,
- 'views': [(False, 'form')],
+ 'res_id': self.id,
+ 'views': [(False, 'form')],
})
- self.env.user.notify_info('My information message', action=action)
+ action["context"].setdefault("params", {})
+ action["context"]["params"]["button_name"] = "Sales"
+ self.env.user.notify_info('My information message', action=action)
-.. figure:: https://raw.githubusercontent.com/OCA/web/15.0/web_notify/static/description/notifications_screenshot.gif
- :scale: 80 %
+.. figure:: https://raw.githubusercontent.com/OCA/web/15.0/web_notify/static/img/notifications_screenshot.gif
:alt: Sample notifications
You can test the behaviour of the notifications by installing this module in a demo database.
Access the users form through Settings -> Users & Companies. You'll see a tab called "Test web notify", here you'll find two buttons that'll allow you test the module.
-.. figure:: https://raw.githubusercontent.com/OCA/web/15.0/web_notify/static/description/test_notifications_demo.png
- :scale: 80 %
+.. figure:: https://raw.githubusercontent.com/OCA/web/15.0/web_notify/static/img/test_notifications_demo.png
:alt: Sample notifications
Bug Tracker
diff --git a/web_notify/readme/USAGE.rst b/web_notify/readme/USAGE.rst
index c86b1ad3a..f0ac617f4 100644
--- a/web_notify/readme/USAGE.rst
+++ b/web_notify/readme/USAGE.rst
@@ -37,26 +37,26 @@ The notifications can bring interactivity with some buttons.
The reload button is activated when sending the notification with:
-
-The action can be used using the ``action`` keyword:
+The action can be used using the ``action`` keyword and we can choose which name to
+give to our button with the ``button_name`` key in the action context `params` key:
.. code-block:: python
action = self.env["ir.actions.act_window"]._for_xml_id('sale.action_orders')
action.update({
- 'res_id': self.id,
- 'views': [(False, 'form')],
+ 'res_id': self.id,
+ 'views': [(False, 'form')],
})
- self.env.user.notify_info('My information message', action=action)
+ action["context"].setdefault("params", {})
+ action["context"]["params"]["button_name"] = "Sales"
+ self.env.user.notify_info('My information message', action=action)
-.. figure:: static/description/notifications_screenshot.gif
- :scale: 80 %
+.. figure:: ../static/img/notifications_screenshot.gif
:alt: Sample notifications
You can test the behaviour of the notifications by installing this module in a demo database.
Access the users form through Settings -> Users & Companies. You'll see a tab called "Test web notify", here you'll find two buttons that'll allow you test the module.
-.. figure:: static/description/test_notifications_demo.png
- :scale: 80 %
+.. figure:: ../static/img/test_notifications_demo.png
:alt: Sample notifications
diff --git a/web_notify/static/description/index.html b/web_notify/static/description/index.html
index 190cb6d18..d5bba9a50 100644
--- a/web_notify/static/description/index.html
+++ b/web_notify/static/description/index.html
@@ -1,3 +1,4 @@
+
@@ -8,10 +9,11 @@
/*
:Author: David Goodger (goodger@python.org)
-:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
+:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
+Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -274,7 +276,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
-pre.code .ln { color: grey; } /* line numbers */
+pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +302,7 @@ span.option {
span.pre {
white-space: pre }
-span.problematic {
+span.problematic, pre.problematic {
color: red }
span.section-subtitle {
@@ -366,7 +368,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!! source digest: sha256:2ea37128bc36b2b82559d0718dff171b9d2e3dcde596a8c8750d6926821862fc
+!! source digest: sha256:387191333e79a8835b7ba7ad61d692b8940bf5bef0ef2a0f9696248c74723ed4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Send instant notification messages to the user in live.
@@ -425,22 +427,25 @@ Two kinds of notification are supported.
Another allowing to send a window / client action
The reload button is activated when sending the notification with:
-The action can be used using the action keyword:
+The action can be used using the action keyword and we can choose which name to
+give to our button with the button_name key in the action context params key:
- action = self.env["ir.actions.act_window"]._for_xml_id('sale.action_orders')
- action.update({
- 'res_id': self.id,
- 'views': [(False, 'form')],
- })
+action = self.env["ir.actions.act_window"]._for_xml_id('sale.action_orders')
+action.update({
+ 'res_id': self.id,
+ 'views': [(False, 'form')],
+})
+action["context"].setdefault("params", {})
+action["context"]["params"]["button_name"] = "Sales"
self.env.user.notify_info('My information message', action=action)
You can test the behaviour of the notifications by installing this module in a demo database.
Access the users form through Settings -> Users & Companies. You’ll see a tab called “Test web notify”, here you’ll find two buttons that’ll allow you test the module.
@@ -477,7 +482,9 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
This module is maintained by the OCA.
-

+
+
+
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
diff --git a/web_notify/static/description/notifications_screenshot.gif b/web_notify/static/description/notifications_screenshot.gif
deleted file mode 100644
index c82aa3e7e..000000000
Binary files a/web_notify/static/description/notifications_screenshot.gif and /dev/null differ
diff --git a/web_notify/static/img/notifications_screenshot.gif b/web_notify/static/img/notifications_screenshot.gif
new file mode 100644
index 000000000..d085fcaa9
Binary files /dev/null and b/web_notify/static/img/notifications_screenshot.gif differ
diff --git a/web_notify/static/description/test_notifications_demo.png b/web_notify/static/img/test_notifications_demo.png
similarity index 100%
rename from web_notify/static/description/test_notifications_demo.png
rename to web_notify/static/img/test_notifications_demo.png
diff --git a/web_notify/static/src/js/services/notification_services.esm.js b/web_notify/static/src/js/services/notification_services.esm.js
index 259b1e4fc..f1ae5deec 100644
--- a/web_notify/static/src/js/services/notification_services.esm.js
+++ b/web_notify/static/src/js/services/notification_services.esm.js
@@ -16,28 +16,34 @@ export const webNotificationService = {
browser.clearTimeout(notif)
);
webNotifTimeouts = {};
- notifications.forEach(function (notif) {
- browser.setTimeout(function () {
- let buttons = [];
-
- if (notif.action) {
- buttons = [
- {
- name: env._t("Open"),
- primary: true,
- onClick: async () => {
- await action.doAction(notif.action);
- },
- },
- ];
- }
- notification.add(Markup(notif.message), {
+ notifications.forEach((notif) => {
+ browser.setTimeout(() => {
+ const notificationRemove = notification.add(Markup(notif.message), {
title: notif.title,
type: notif.type,
sticky: notif.sticky,
className: notif.className,
messageIsHtml: notif.html,
- buttons: buttons,
+ buttons:
+ notif.action &&
+ notif.action.context &&
+ notif.action.context.params
+ ? [
+ {
+ name:
+ notif.action.context.params.button_name ||
+ env._t("Open"),
+ primary: true,
+ onClick: async function () {
+ await action.doAction(notif.action);
+ notificationRemove();
+ },
+ icon:
+ notif.action.context.params.button_icon ||
+ undefined,
+ },
+ ]
+ : [],
});
});
});