summaryrefslogtreecommitdiff
path: root/doc/reference/javascript_reference.rst
diff options
context:
space:
mode:
authorRomeo Fragomeli <rfr@odoo.com>2019-10-09 09:55:59 +0000
committerfw-bot <otis@odoo.com>2019-10-14 12:11:23 +0000
commit547d2d87fcf315314e3da0aad4771a3c4830b581 (patch)
tree8d65b31ca79523caf31cd3bd84785734f832732e /doc/reference/javascript_reference.rst
parent3e5cc15d16e7f0dd38e2bfc3edd2b4a241e0d5ac (diff)
[FIX] web: not possible to show a notification via client action
Before this commit, it was not possible to show a message using a client action. (e.g. show a success message only with core in Python) Now, it's possible using a client action. This client action call displayNotification and so we can use the same options also. A test is added to be sure that this action do not change the current action Note: in the future a custom registry may be created in a refactoring to specific function action registry. X-original-commit: 8775fd670b6b3ec19a77fc0eab72d2223baa36c8
Diffstat (limited to 'doc/reference/javascript_reference.rst')
-rw-r--r--doc/reference/javascript_reference.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/reference/javascript_reference.rst b/doc/reference/javascript_reference.rst
index f724485f86a..6a1dbdd7599 100644
--- a/doc/reference/javascript_reference.rst
+++ b/doc/reference/javascript_reference.rst
@@ -1213,6 +1213,10 @@ The notification system in Odoo is designed with the following components:
destroy notifications whenever a request is done (with a custom_event). Note
that the web client is a service provider.
+- a client action *display_notification*: this allows to trigger the display
+ of a notification from python (e.g. in the method called when the user
+ clicked on a button of type object).
+
- two helper functions in *ServiceMixin*: *do_notify* and *do_warn*
@@ -1260,6 +1264,21 @@ Here are two examples on how to use these methods:
this.do_warn(_t("Error"), _t("Filter name is required."));
+Here an example in python:
+
+.. code-block:: python
+
+ # note that we call _(string) on the text to make sure it is properly translated.
+ def show_notification(self):
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'display_notification',
+ 'params': {
+ 'title': _('Success'),
+ 'message': _('Your signature request has been sent.'),
+ 'sticky': False,
+ }
+ }
Systray
=======