mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_notify: action button name and close
- We can now set a button name to the notification action. - We can set an icon button as well. - After the button is clicked, the notification gets closed.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user