diff options
| author | eco-odoo <eco@odoo.com> | 2018-07-03 10:28:44 +0200 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2018-07-20 11:59:12 +0200 |
| commit | c1498ff36be4ce0b175f340e2f5690a37421ccd7 (patch) | |
| tree | 498abacd2425b83c54759a4565ddb95702947639 /doc | |
| parent | 0dd6a0b2bf0be0698d21e039ad4ead33133d8267 (diff) | |
[IMP] web: add option to display a banner above a view
Add a banner_route attribute to AbstractView to allow fetching html from a
controller route and displaying it above the view.
The initial use case was the onboarding panels.
Supported views are the ones inheriting both AbstractView and AbstractController.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/reference/views.rst | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/doc/reference/views.rst b/doc/reference/views.rst index 08848604926..8a733dedee4 100644 --- a/doc/reference/views.rst +++ b/doc/reference/views.rst @@ -44,6 +44,45 @@ otherwise. ``application`` website feature defining togglable views. By default, views are always applied +``banner_route`` + a route address to be fetched and prepended to the view. + + If this attribute is set, the + :ref:`controller route url<reference/http/controllers>` will be fetched and + displayed above the view. The json response from the controller should + contain an "html" key. + + If the html contains a stylesheet <link> tag, it will be + removed and appended to <head>. + + To interact with the backend you can use <a type="action"> tags. Please take + a look at the documentation of the _onActionClicked method of + AbstractController (*addons/web/static/src/js/views/abstract_controller.js*) + for more details. + + Only views extending AbstractView and AbstractController can use this + attribute, like :ref:`reference/views/form`, :ref:`reference/views/kanban`, + :ref:`reference/views/list`, ... + + Example: + + .. code-block:: xml + + <tree banner_route="/module_name/hello" /> + + .. code-block:: python + + class MyController(odoo.http.Controller): + @http.route('/module_name/hello', auth='user', type='json') + def hello(self): + return { + 'html': """ + <div> + <link href="/module_name/static/src/css/banner.css" + rel="stylesheet"> + <h1>hello, world</h1> + </div> """ + } .. _reference/views/inheritance: |
