From 107ca7da9d86f2beb4f323c22fb03f44ec4eb1e8 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 20 Jul 2018 10:31:18 +0200 Subject: [PATCH] Update documentation of server_environment, bump --- server_environment/README.rst | 60 ++++++++++++++++++++++-------- server_environment/__manifest__.py | 1 + 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/server_environment/README.rst b/server_environment/README.rst index e1b9749..ca0bae7 100644 --- a/server_environment/README.rst +++ b/server_environment/README.rst @@ -3,17 +3,20 @@ :alt: License: GPL-3 ================== -server environment +Server Environment ================== This module provides a way to define an environment in the main Odoo configuration file and to read some configurations from files depending on the configured environment: you define the environment in the main configuration file, and the values for the various possible -environments are stored in the `server_environment_files` companion +environments are stored in the ``server_environment_files`` companion module. -All the settings will be read only and visible under the Configuration +The ``server_environment_files`` module is optional, the values can be set using +an environment variable with a fallback on default values in the database. + +The configuration read from the files are visible under the Configuration menu. If you are not in the 'dev' environment you will not be able to see the values contained in keys named '*passw*'. @@ -21,14 +24,14 @@ Installation ============ By itself, this module does little. See for instance the -`mail_environment` addon which depends on this one to allow configuring +``mail_environment`` addon which depends on this one to allow configuring the incoming and outgoing mail servers depending on the environment. -To install this module, you need to provide a companion module called -`server_environment_files`. You can copy and customize the provided -`server_environment_files_sample` module for this purpose. -You can provide additional options in environment variables -``SERVER_ENV_CONFIG`` and ``SERVER_ENV_CONFIG_SECRET``. +You can store your configuration values in a companion module called +``server_environment_files``. You can copy and customize the provided +``server_environment_files_sample`` module for this purpose. Alternatively, you +can provide them in environment variable ``SERVER_ENV_CONFIG`` and +``SERVER_ENV_CONFIG_SECRET``. Configuration @@ -65,7 +68,7 @@ Environment variable You can define configuration in the environment variable ``SERVER_ENV_CONFIG`` and/or ``SERVER_ENV_CONFIG_SECRET``. The 2 variables are handled the exact same way, this is only a convenience for the deployment where you can isolate the -secrets in a different, encrypted, file. This is a multi-line environment variable +secrets in a different, encrypted, file. They are multi-line environment variables in the same configparser format than the files. If you used options in ``server_environment_files``, the options set in the environment variable overrides them. @@ -75,7 +78,6 @@ the content of the variable must be set accordingly to the running environment. Example of setup: - A public file, containing that will contain public variables:: # These variables are not odoo standard variables, @@ -106,17 +108,43 @@ A second file which is encrypted and contains secrets:: sftp_password=xxxxxxxxx " +Default values +-------------- + +When using the ``server.env.mixin`` mixin, for each env-computed field, a +companion field ``_env_default`` is created. This field is not +environment-dependent. It's a fallback value used when no key is set in +configuration files / environment variable. + +When the default field is used, the field is made editable on Odoo. + +Note: a present key with an empty value do not fallback on the default field. + +Keychain integration +-------------------- + +Read the documentation of the class `models/server_env_mixin.py +`_. + + Usage ===== -To use this module, in your code, you can follow this example:: +You can include a mixin in your model and configure the env-computed fields +by an override of ``_server_env_fields``. - from openerp.addons.server_environment import serv_config - for key, value in serv_config.items('external_service.ftp'): - print (key, value) +:: - serv_config.get('external_service.ftp', 'tls') + class StorageBackend(models.Model): + _name = "storage.backend" + _inherit = ["storage.backend", "server.env.mixin"] + @property + def _server_env_fields(self): + return {"directory_path": {'getter': 'get'}} + +Read the documentation of the class and methods in `models/server_env_mixin.py +`__. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas diff --git a/server_environment/__manifest__.py b/server_environment/__manifest__.py index 3d9dc22..bd30706 100644 --- a/server_environment/__manifest__.py +++ b/server_environment/__manifest__.py @@ -20,6 +20,7 @@ { "name": "server configuration environment files", + "version": "11.0.1.2.0", "depends": [ "base", "base_sparse_field",