From 1e6c12be30a3328af4565315b1ff9a9539856806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 1 Nov 2021 07:49:44 +0000 Subject: [PATCH] [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#1249 Signed-off-by: Victor Feyens (vfe) --- .../reference/frontend/framework_overview.rst | 16 +++++++++++----- .../developer/reference/frontend/services.rst | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/content/developer/reference/frontend/framework_overview.rst b/content/developer/reference/frontend/framework_overview.rst index a21b26f49..84e0e84bc 100644 --- a/content/developer/reference/frontend/framework_overview.rst +++ b/content/developer/reference/frontend/framework_overview.rst @@ -100,7 +100,7 @@ can access it using ``this.env``). Here is a description of what Odoo adds to the shared ``env`` object: .. list-table:: - :widths: 30 70 + :widths: 25 75 :header-rows: 1 * - Key @@ -110,14 +110,14 @@ the shared ``env`` object: * - `bus` - :ref:`main bus `, used to coordinate some generic events * - `services` - - all deployed services (should usually be accessed with the `useService` hook) + - all deployed :ref:`services ` (should usually be accessed + with the `useService` hook) * - `debug` - - string. If non empty, the web client is in :ref:`debug mode` + - string. If non empty, the web client is in :ref:`debug mode ` * - `_t` - translation function * - `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 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'); +.. 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 =============== diff --git a/content/developer/reference/frontend/services.rst b/content/developer/reference/frontend/services.rst index de49788b0..a3b54e56a 100644 --- a/content/developer/reference/frontend/services.rst +++ b/content/developer/reference/frontend/services.rst @@ -111,7 +111,7 @@ Reference List ============== .. list-table:: - :widths: 30 70 + :widths: 25 75 :header-rows: 1 * - Technical Name