diff --git a/pandoc-3.1.9-1-amd64.deb b/pandoc-3.1.9-1-amd64.deb new file mode 100644 index 0000000..77ae8bb Binary files /dev/null and b/pandoc-3.1.9-1-amd64.deb differ diff --git a/server_environment/README.rst b/server_environment/README.rst index a2b0113..9fa935b 100644 --- a/server_environment/README.rst +++ b/server_environment/README.rst @@ -17,31 +17,31 @@ server configuration environment files :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github - :target: https://github.com/OCA/server-env/tree/16.0/server_environment + :target: https://github.com/OCA/server-env/tree/17.0/server_environment :alt: OCA/server-env .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/server-env-16-0/server-env-16-0-server_environment + :target: https://translation.odoo-community.org/projects/server-env-17-0/server-env-17-0-server_environment :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/server-env&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-env&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| 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 -module. +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 module. -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 ``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 the defined secret keys -(by default : '*passw*', '*key*', '*secret*' and '*token*'). +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 the defined secret keys (by +default : '*passw*', '*key*', '*secret*' and '*token*'). **Table of contents** @@ -52,104 +52,112 @@ Installation ============ By itself, this module does little. See for instance the -``mail_environment`` addon which depends on this one to allow configuring -the incoming and outgoing mail servers depending on the environment. +``mail_environment`` addon which depends on this one to allow +configuring the incoming and outgoing mail servers depending on the +environment. 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 variables ``SERVER_ENV_CONFIG`` and -``SERVER_ENV_CONFIG_SECRET``. +``server_environment_files_sample`` module for this purpose. +Alternatively, you can provide them in environment variables +``SERVER_ENV_CONFIG`` and ``SERVER_ENV_CONFIG_SECRET``. Configuration ============= To configure this module, you need to edit the main configuration file of your instance, and add a directive called ``running_env``. Commonly -used values are 'dev', 'test', 'production':: +used values are 'dev', 'test', 'production': - [options] - running_env=dev +:: -Values associated to keys containing 'passw' are only displayed in the 'dev' -environment. + [options] + running_env=dev -If you don't provide any value, `test` is used as a safe default. +Values associated to keys containing 'passw' are only displayed in the +'dev' environment. + +If you don't provide any value, test is used as a safe default. You have several possibilities to set configuration values: server_environment_files -~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------ -You can edit the settings you need in the ``server_environment_files`` addon. The -``server_environment_files_sample`` can be used as an example: +You can edit the settings you need in the ``server_environment_files`` +addon. The ``server_environment_files_sample`` can be used as an +example: -* values common to all / most environments can be stored in the - ``default/`` directory using the .ini file syntax; -* each environment you need to define is stored in its own directory - and can override or extend default values; -* you can override or extend values in the main configuration - file of your instance; +- values common to all / most environments can be stored in the + ``default/`` directory using the .ini file syntax; +- each environment you need to define is stored in its own directory + and can override or extend default values; +- you can override or extend values in the main configuration file of + your instance; 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. 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 override them. +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. 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 override them. -The options in the environment variable are not dependent of ``running_env``, -the content of the variable must be set accordingly to the running environment. +The options in the environment variable are not dependent of +``running_env``, 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:: +A public file, containing that will contain public variables: - # These variables are not odoo standard variables, - # they are there to represent what your file could look like - export WORKERS='8' - export MAX_CRON_THREADS='1' - export LOG_LEVEL=info - export LOG_HANDLER=":INFO" - export DB_MAXCONN=5 +:: - # server environment options - export SERVER_ENV_CONFIG=" - [storage_backend.my_sftp] - sftp_server=10.10.10.10 - sftp_login=foo - sftp_port=22200 - directory_path=Odoo - " + # These variables are not odoo standard variables, + # they are there to represent what your file could look like + export WORKERS='8' + export MAX_CRON_THREADS='1' + export LOG_LEVEL=info + export LOG_HANDLER=":INFO" + export DB_MAXCONN=5 -A second file which is encrypted and contains secrets:: + # server environment options + export SERVER_ENV_CONFIG=" + [storage_backend.my_sftp] + sftp_server=10.10.10.10 + sftp_login=foo + sftp_port=22200 + directory_path=Odoo + " - # This variable is not an odoo standard variable, - # it is there to represent what your file could look like - export DB_PASSWORD='xxxxxxxxx' - # server environment options - export SERVER_ENV_CONFIG_SECRET=" - [storage_backend.my_sftp] - sftp_password=xxxxxxxxx - " +A second file which is encrypted and contains secrets: + +:: + + # This variable is not an odoo standard variable, + # it is there to represent what your file could look like + export DB_PASSWORD='xxxxxxxxx' + # server environment options + export SERVER_ENV_CONFIG_SECRET=" + [storage_backend.my_sftp] + sftp_password=xxxxxxxxx + " **WARNING** - `my_sftp` must match the name of the record. - If you want something more reliable use `server.env.techname.mixin` - and use `tech_name` field to reference records. - See "USAGE". - + my_sftp must match the name of the record. If you want something more + reliable use server.env.techname.mixin and use tech_name field to + reference records. See "USAGE". 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 +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. @@ -157,49 +165,51 @@ When the default field is used, the field is made editable on Odoo. Note: empty environment keys always take precedence over default fields - Server environment integration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------------ -Read the documentation of the class `models/server_env_mixin.py -`_. +Read the documentation of the class +`models/server_env_mixin.py `__. Usage ===== -You can include a mixin in your model and configure the env-computed fields -by an override of ``_server_env_fields``. +You can include a mixin in your model and configure the env-computed +fields by an override of ``_server_env_fields``. :: - class StorageBackend(models.Model): - _name = "storage.backend" - _inherit = ["storage.backend", "server.env.mixin"] + class StorageBackend(models.Model): + _name = "storage.backend" + _inherit = ["storage.backend", "server.env.mixin"] - @property - def _server_env_fields(self): - return {"directory_path": {}} + @property + def _server_env_fields(self): + return {"directory_path": {}} -Read the documentation of the class and methods in `models/server_env_mixin.py -`__. +Read the documentation of the class and methods in +`models/server_env_mixin.py `__. +If you want to have a technical name to reference: -If you want to have a technical name to reference:: +:: - class StorageBackend(models.Model): - _name = "storage.backend" - _inherit = ["storage.backend", "server.env.techname.mixin", "server.env.mixin"] + class StorageBackend(models.Model): + _name = "storage.backend" + _inherit = ["storage.backend", "server.env.techname.mixin", "server.env.mixin"] - [...] + [...] Known issues / Roadmap ====================== -* it is not possible to set the environment from the command line. A - configuration file must be used. -* the module does not allow to set low level attributes such as database server, etc. -* `server.env.techname.mixin`'s `tech_name` field could leverage the new option - for computable / writable fields and get rid of some onchange / read / write code. +- it is not possible to set the environment from the command line. A + configuration file must be used. +- the module does not allow to set low level attributes such as + database server, etc. +- server.env.techname.mixin's tech_name field could leverage the new + option for computable / writable fields and get rid of some onchange + / read / write code. Bug Tracker =========== @@ -207,7 +217,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -215,28 +225,28 @@ Credits ======= Authors -~~~~~~~ +------- * Camptocamp Contributors -~~~~~~~~~~~~ +------------ -* Florent Xicluna (Wingo) -* Nicolas Bessi -* Alexandre Fayolle -* Daniel Reis -* Holger Brunn -* Leonardo Pistone -* Adrien Peiffer -* Thierry Ducrest -* Guewen Baconnier -* Thomas Binfeld -* Stéphane Bidoul -* Simone Orsi +- Florent Xicluna (Wingo) +- Nicolas Bessi +- Alexandre Fayolle +- Daniel Reis +- Holger Brunn +- Leonardo Pistone +- Adrien Peiffer +- Thierry Ducrest +- Guewen Baconnier +- Thomas Binfeld +- Stéphane Bidoul +- Simone Orsi Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -248,6 +258,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/server-env `_ project on GitHub. +This module is part of the `OCA/server-env `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/server_environment/models/server_env_mixin.py b/server_environment/models/server_env_mixin.py index db7d847..dba118b 100644 --- a/server_environment/models/server_env_mixin.py +++ b/server_environment/models/server_env_mixin.py @@ -338,7 +338,7 @@ class ServerEnvMixin(models.AbstractModel): options = self._server_env_fields[base_field_name] if options and options.get("no_default_field"): return "" - return "{}_env_default".format(base_field_name) + return f"{base_field_name}_env_default" def _server_env_is_editable_fieldname(self, base_field_name): """Return the name of the field for "is editable" @@ -346,7 +346,7 @@ class ServerEnvMixin(models.AbstractModel): This is the field used to tell if the env-computed field can be edited. """ - return "{}_env_is_editable".format(base_field_name) + return f"{base_field_name}_env_is_editable" def _server_env_transform_field_to_read_from_env(self, field): """Transform the original field in a computed field""" diff --git a/server_environment/pyproject.toml b/server_environment/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/server_environment/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/server_environment/readme/CONFIGURE.md b/server_environment/readme/CONFIGURE.md new file mode 100644 index 0000000..af8d3b2 --- /dev/null +++ b/server_environment/readme/CONFIGURE.md @@ -0,0 +1,94 @@ +To configure this module, you need to edit the main configuration file +of your instance, and add a directive called `running_env`. Commonly +used values are 'dev', 'test', 'production': + + [options] + running_env=dev + +Values associated to keys containing 'passw' are only displayed in the +'dev' environment. + +If you don't provide any value, test is used as a safe default. + +You have several possibilities to set configuration values: + +## server_environment_files + +You can edit the settings you need in the `server_environment_files` +addon. The `server_environment_files_sample` can be used as an example: + +- values common to all / most environments can be stored in the + `default/` directory using the .ini file syntax; +- each environment you need to define is stored in its own directory and + can override or extend default values; +- you can override or extend values in the main configuration file of + your instance; + +## 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. 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 +override them. + +The options in the environment variable are not dependent of +`running_env`, 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, + # they are there to represent what your file could look like + export WORKERS='8' + export MAX_CRON_THREADS='1' + export LOG_LEVEL=info + export LOG_HANDLER=":INFO" + export DB_MAXCONN=5 + + # server environment options + export SERVER_ENV_CONFIG=" + [storage_backend.my_sftp] + sftp_server=10.10.10.10 + sftp_login=foo + sftp_port=22200 + directory_path=Odoo + " + +A second file which is encrypted and contains secrets: + + # This variable is not an odoo standard variable, + # it is there to represent what your file could look like + export DB_PASSWORD='xxxxxxxxx' + # server environment options + export SERVER_ENV_CONFIG_SECRET=" + [storage_backend.my_sftp] + sftp_password=xxxxxxxxx + " + +**WARNING** + +> my_sftp must match the name of the record. If you want something more +> reliable use server.env.techname.mixin and use tech_name field to +> reference records. See "USAGE". + +## 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: empty environment keys always take precedence over default fields + +## Server environment integration + +Read the documentation of the class +[models/server_env_mixin.py](models/server_env_mixin.py). diff --git a/server_environment/readme/CONFIGURE.rst b/server_environment/readme/CONFIGURE.rst deleted file mode 100644 index b3e8024..0000000 --- a/server_environment/readme/CONFIGURE.rst +++ /dev/null @@ -1,99 +0,0 @@ -To configure this module, you need to edit the main configuration file -of your instance, and add a directive called ``running_env``. Commonly -used values are 'dev', 'test', 'production':: - - [options] - running_env=dev - -Values associated to keys containing 'passw' are only displayed in the 'dev' -environment. - -If you don't provide any value, `test` is used as a safe default. - -You have several possibilities to set configuration values: - -server_environment_files -~~~~~~~~~~~~~~~~~~~~~~~~ - -You can edit the settings you need in the ``server_environment_files`` addon. The -``server_environment_files_sample`` can be used as an example: - -* values common to all / most environments can be stored in the - ``default/`` directory using the .ini file syntax; -* each environment you need to define is stored in its own directory - and can override or extend default values; -* you can override or extend values in the main configuration - file of your instance; - -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. 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 override them. - -The options in the environment variable are not dependent of ``running_env``, -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, - # they are there to represent what your file could look like - export WORKERS='8' - export MAX_CRON_THREADS='1' - export LOG_LEVEL=info - export LOG_HANDLER=":INFO" - export DB_MAXCONN=5 - - # server environment options - export SERVER_ENV_CONFIG=" - [storage_backend.my_sftp] - sftp_server=10.10.10.10 - sftp_login=foo - sftp_port=22200 - directory_path=Odoo - " - -A second file which is encrypted and contains secrets:: - - # This variable is not an odoo standard variable, - # it is there to represent what your file could look like - export DB_PASSWORD='xxxxxxxxx' - # server environment options - export SERVER_ENV_CONFIG_SECRET=" - [storage_backend.my_sftp] - sftp_password=xxxxxxxxx - " - -**WARNING** - - `my_sftp` must match the name of the record. - If you want something more reliable use `server.env.techname.mixin` - and use `tech_name` field to reference records. - See "USAGE". - - -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: empty environment keys always take precedence over default fields - - -Server environment integration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Read the documentation of the class `models/server_env_mixin.py -`_. diff --git a/server_environment/readme/CONTRIBUTORS.md b/server_environment/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..2ad99dc --- /dev/null +++ b/server_environment/readme/CONTRIBUTORS.md @@ -0,0 +1,12 @@ +- Florent Xicluna (Wingo) \<\> +- Nicolas Bessi \<\> +- Alexandre Fayolle \<\> +- Daniel Reis \<\> +- Holger Brunn \<\> +- Leonardo Pistone \<\> +- Adrien Peiffer \<\> +- Thierry Ducrest \<\> +- Guewen Baconnier \<\> +- Thomas Binfeld \<\> +- Stéphane Bidoul \<\> +- Simone Orsi \<\> diff --git a/server_environment/readme/CONTRIBUTORS.rst b/server_environment/readme/CONTRIBUTORS.rst deleted file mode 100644 index cb37929..0000000 --- a/server_environment/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,12 +0,0 @@ -* Florent Xicluna (Wingo) -* Nicolas Bessi -* Alexandre Fayolle -* Daniel Reis -* Holger Brunn -* Leonardo Pistone -* Adrien Peiffer -* Thierry Ducrest -* Guewen Baconnier -* Thomas Binfeld -* Stéphane Bidoul -* Simone Orsi diff --git a/server_environment/readme/DESCRIPTION.md b/server_environment/readme/DESCRIPTION.md new file mode 100644 index 0000000..f08c22d --- /dev/null +++ b/server_environment/readme/DESCRIPTION.md @@ -0,0 +1,14 @@ +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 module. + +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 the defined secret keys (by +default : '*passw*', '*key*', '*secret*' and '*token*'). diff --git a/server_environment/readme/DESCRIPTION.rst b/server_environment/readme/DESCRIPTION.rst deleted file mode 100644 index 8fc7356..0000000 --- a/server_environment/readme/DESCRIPTION.rst +++ /dev/null @@ -1,14 +0,0 @@ -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 -module. - -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 the defined secret keys -(by default : '*passw*', '*key*', '*secret*' and '*token*'). diff --git a/server_environment/readme/INSTALL.md b/server_environment/readme/INSTALL.md new file mode 100644 index 0000000..8981a4c --- /dev/null +++ b/server_environment/readme/INSTALL.md @@ -0,0 +1,9 @@ +By itself, this module does little. See for instance the +`mail_environment` addon which depends on this one to allow configuring +the incoming and outgoing mail servers depending on the environment. + +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 variables +`SERVER_ENV_CONFIG` and `SERVER_ENV_CONFIG_SECRET`. diff --git a/server_environment/readme/INSTALL.rst b/server_environment/readme/INSTALL.rst deleted file mode 100644 index 8ad360c..0000000 --- a/server_environment/readme/INSTALL.rst +++ /dev/null @@ -1,9 +0,0 @@ -By itself, this module does little. See for instance the -``mail_environment`` addon which depends on this one to allow configuring -the incoming and outgoing mail servers depending on the environment. - -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 variables ``SERVER_ENV_CONFIG`` and -``SERVER_ENV_CONFIG_SECRET``. diff --git a/server_environment/readme/ROADMAP.md b/server_environment/readme/ROADMAP.md new file mode 100644 index 0000000..463bd03 --- /dev/null +++ b/server_environment/readme/ROADMAP.md @@ -0,0 +1,7 @@ +- it is not possible to set the environment from the command line. A + configuration file must be used. +- the module does not allow to set low level attributes such as database + server, etc. +- server.env.techname.mixin's tech_name field could leverage the new + option for computable / writable fields and get rid of some onchange / + read / write code. diff --git a/server_environment/readme/ROADMAP.rst b/server_environment/readme/ROADMAP.rst deleted file mode 100644 index 58107c9..0000000 --- a/server_environment/readme/ROADMAP.rst +++ /dev/null @@ -1,5 +0,0 @@ -* it is not possible to set the environment from the command line. A - configuration file must be used. -* the module does not allow to set low level attributes such as database server, etc. -* `server.env.techname.mixin`'s `tech_name` field could leverage the new option - for computable / writable fields and get rid of some onchange / read / write code. diff --git a/server_environment/readme/USAGE.rst b/server_environment/readme/USAGE.md similarity index 68% rename from server_environment/readme/USAGE.rst rename to server_environment/readme/USAGE.md index d12b21d..e859849 100644 --- a/server_environment/readme/USAGE.rst +++ b/server_environment/readme/USAGE.md @@ -1,7 +1,5 @@ -You can include a mixin in your model and configure the env-computed fields -by an override of ``_server_env_fields``. - -:: +You can include a mixin in your model and configure the env-computed +fields by an override of `_server_env_fields`. class StorageBackend(models.Model): _name = "storage.backend" @@ -11,11 +9,10 @@ by an override of ``_server_env_fields``. def _server_env_fields(self): return {"directory_path": {}} -Read the documentation of the class and methods in `models/server_env_mixin.py -`__. +Read the documentation of the class and methods in +[models/server_env_mixin.py](models/server_env_mixin.py). - -If you want to have a technical name to reference:: +If you want to have a technical name to reference: class StorageBackend(models.Model): _name = "storage.backend" diff --git a/server_environment/server_env.py b/server_environment/server_env.py index ed16e84..8a07a0f 100644 --- a/server_environment/server_env.py +++ b/server_environment/server_env.py @@ -111,9 +111,7 @@ def _load_config_from_server_env_files(config_p): try: config_p.read(conf_files) except Exception as e: - raise Exception( - 'Cannot read config files "{}": {}'.format(conf_files, e) - ) from e + raise Exception(f'Cannot read config files "{conf_files}": {e}') from e def _load_config_from_rcfile(config_p): @@ -129,7 +127,7 @@ def _load_config_from_env(config_p): config_p.read_string(env_config) except configparser.Error as err: raise Exception( - "{} content could not be parsed: {}".format(varname, err) + f"{varname} content could not be parsed: {err}" ) from err @@ -182,7 +180,7 @@ class ServerConfiguration(models.TransientModel): @classmethod def _format_key(cls, section, key): - return "{}_I_{}".format(section, key) + return f"{section}_I_{key}" @property def show_passwords(self): diff --git a/server_environment/static/description/index.html b/server_environment/static/description/index.html index c3c935b..ca3c755 100644 --- a/server_environment/static/description/index.html +++ b/server_environment/static/description/index.html @@ -369,19 +369,19 @@ ul.auto-toc { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:681af9ccb320ef4e5866b4dfcb9ed2d8d19abae84f71d251cdc8376303f40c01 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Production/Stable License: LGPL-3 OCA/server-env Translate me on Weblate Try me on Runboat

+

Production/Stable License: LGPL-3 OCA/server-env Translate me on Weblate Try me on Runboat

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 -module.

-

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 the defined secret keys -(by default : ‘passw’, ‘key’, ‘secret’ and ‘token’).

+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 module.

+

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 the defined secret keys (by +default : ‘passw’, ‘key’, ‘secret’ and ‘token’).

Table of contents

    @@ -407,13 +407,14 @@ see the values contained in the defined secret keys

    Installation

    By itself, this module does little. See for instance the -mail_environment addon which depends on this one to allow configuring -the incoming and outgoing mail servers depending on the environment.

    +mail_environment addon which depends on this one to allow +configuring the incoming and outgoing mail servers depending on the +environment.

    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 variables SERVER_ENV_CONFIG and -SERVER_ENV_CONFIG_SECRET.

    +server_environment_files_sample module for this purpose. +Alternatively, you can provide them in environment variables +SERVER_ENV_CONFIG and SERVER_ENV_CONFIG_SECRET.

    Configuration

    @@ -424,34 +425,37 @@ used values are ‘dev’, ‘test’, ‘production’:

    [options] running_env=dev -

    Values associated to keys containing ‘passw’ are only displayed in the ‘dev’ -environment.

    -

    If you don’t provide any value, test is used as a safe default.

    +

    Values associated to keys containing ‘passw’ are only displayed in the +‘dev’ environment.

    +

    If you don’t provide any value, test is used as a safe default.

    You have several possibilities to set configuration values:

    server_environment_files

    -

    You can edit the settings you need in the server_environment_files addon. The -server_environment_files_sample can be used as an example:

    +

    You can edit the settings you need in the server_environment_files +addon. The server_environment_files_sample can be used as an +example:

    • values common to all / most environments can be stored in the default/ directory using the .ini file syntax;
    • each environment you need to define is stored in its own directory and can override or extend default values;
    • -
    • you can override or extend values in the main configuration -file of your instance;
    • +
    • you can override or extend values in the main configuration file of +your instance;

    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. 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 override them.

    -

    The options in the environment variable are not dependent of running_env, -the content of the variable must be set accordingly to the running environment.

    +

    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. 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 override them.

    +

    The options in the environment variable are not dependent of +running_env, 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:

    @@ -485,15 +489,14 @@ sftp_password=xxxxxxxxx
     

    WARNING

    -my_sftp must match the name of the record. -If you want something more reliable use server.env.techname.mixin -and use tech_name field to reference records. -See “USAGE”.
    +my_sftp must match the name of the record. If you want something more +reliable use server.env.techname.mixin and use tech_name field to +reference records. See “USAGE”.

    Default values

    -

    When using the server.env.mixin mixin, for each env-computed field, a -companion field <field>_env_default is created. This field is not +

    When using the server.env.mixin mixin, for each env-computed field, +a companion field <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.

    @@ -501,13 +504,14 @@ configuration files / environment variable.

    Server environment integration

    -

    Read the documentation of the class models/server_env_mixin.py.

    +

    Read the documentation of the class +models/server_env_mixin.py.

    Usage

    -

    You can include a mixin in your model and configure the env-computed fields -by an override of _server_env_fields.

    +

    You can include a mixin in your model and configure the env-computed +fields by an override of _server_env_fields.

     class StorageBackend(models.Model):
         _name = "storage.backend"
    @@ -517,7 +521,8 @@ class StorageBackend(models.Model):
         def _server_env_fields(self):
             return {"directory_path": {}}
     
    -

    Read the documentation of the class and methods in models/server_env_mixin.py.

    +

    Read the documentation of the class and methods in +models/server_env_mixin.py.

    If you want to have a technical name to reference:

     class StorageBackend(models.Model):
    @@ -532,9 +537,11 @@ class StorageBackend(models.Model):
     
    • it is not possible to set the environment from the command line. A configuration file must be used.
    • -
    • the module does not allow to set low level attributes such as database server, etc.
    • -
    • server.env.techname.mixin’s tech_name field could leverage the new option -for computable / writable fields and get rid of some onchange / read / write code.
    • +
    • the module does not allow to set low level attributes such as +database server, etc.
    • +
    • server.env.techname.mixin’s tech_name field could leverage the new +option for computable / writable fields and get rid of some onchange +/ read / write code.
    @@ -542,7 +549,7 @@ for computable / writable fields and get rid of some onchange / read / write cod

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -577,7 +584,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/server-env project on GitHub.

    +

    This module is part of the OCA/server-env project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.