[IMP] developer: improve section on env

- add a link to services
- add a note that the env is quite powerful
- reformat the table with the list-table role, to make it easier to edit

closes odoo/documentation#1268

X-original-commit: 1e6c12be30
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Géry Debongnie 2021-11-01 07:49:44 +00:00
parent 431839da7d
commit 54203049fa
2 changed files with 12 additions and 6 deletions

View File

@ -100,7 +100,7 @@ can access it using ``this.env``). Here is a description of what Odoo adds to
the shared ``env`` object: the shared ``env`` object:
.. list-table:: .. list-table::
:widths: 30 70 :widths: 25 75
:header-rows: 1 :header-rows: 1
* - Key * - Key
@ -110,14 +110,14 @@ the shared ``env`` object:
* - `bus` * - `bus`
- :ref:`main bus <javascript/bus>`, used to coordinate some generic events - :ref:`main bus <javascript/bus>`, used to coordinate some generic events
* - `services` * - `services`
- all deployed services (should usually be accessed with the `useService` hook) - all deployed :ref:`services <javascript/services>` (should usually be accessed
with the `useService` hook)
* - `debug` * - `debug`
- string. If non empty, the web client is in :ref:`debug mode<javascript/debug_mode>` - string. If non empty, the web client is in :ref:`debug mode <javascript/debug_mode>`
* - `_t` * - `_t`
- translation function - translation function
* - `isSmall` * - `isSmall`
- boolean. If true, the web client is currently in mobile mode - boolean. If true, the web client is currently in mobile mode (screen width <= 767px)
So, for example, to translate a string in a component (note: templates are So, for example, to translate a string in a component (note: templates are
automatically translated, so no specific action is required in that case), one automatically translated, so no specific action is required in that case), one
@ -128,6 +128,12 @@ can do this:
const someString = this.env._t('some text'); const someString = this.env._t('some text');
.. note::
Having a reference to the environment is quite powerful, because it provides
access to all services. This is useful in many cases: for example,
user menu items are mostly defined as a string, and a function taking the `env`
as unique argument. This is enough to express all user menu needs.
Building Blocks Building Blocks
=============== ===============

View File

@ -111,7 +111,7 @@ Reference List
============== ==============
.. list-table:: .. list-table::
:widths: 30 70 :widths: 25 75
:header-rows: 1 :header-rows: 1
* - Technical Name * - Technical Name