odoo14-addon-server-environment


Nameodoo14-addon-server-environment JSON
Version 14.0.2.2.1 PyPI version JSON
download
home_pagehttps://github.com/OCA/server-env
Summarymove some configurations out of the database
upload_time2024-03-23 06:50:31
maintainerNone
docs_urlNone
authorCamptocamp,Odoo Community Association (OCA)
requires_python>=3.6
licenseLGPL-3
keywords
VCS
bugtrack_url
requirements cryptography
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ======================================
server configuration environment files
======================================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:e7a36837fb5174b0dc678aa303952274898fe6a9b995b811a7155ac048e19d84
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
    :target: https://odoo-community.org/page/development-status
    :alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
    :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/14.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-14-0/server-env-14-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=14.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.

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. you
will be able to overwrite some odoo options.

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**

.. contents::
   :local:

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.

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

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'::

  [options]
  running_env=dev

Or set the `RUNNING_ENV` or `ODOO_STAGE` environment variable. If both all are set config file
will take the precedence on environment and `RUNNING_ENV` over `ODOO_STAGE`.

`ODOO_STAGE` is used for odoo.sh platform where we can't set `RUNNING_ENV`, possible
observed values are `production`, `staging` and `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;
* In some platforms (like odoo.sh where production config file is copied to staging)
  it can be usefull to overwrite options write in the `[options]` section. You must
  allow the overwrite by adding `server_environment_allow_overwrite_options_section = True``
  to the former `odoo.cfg` config file or through the environment variable:
  `export SERVER_ENVIRONMENT_ALLOW_OVERWRITE_OPTIONS_SECTION=True` (if both are set
  config file take precedent).

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 ``<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>`_.

Usage
=====

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"]

        @property
        def _server_env_fields(self):
            return {"directory_path": {}}

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::

    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.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-env/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 <https://github.com/OCA/server-env/issues/new?body=module:%20server_environment%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* Florent Xicluna (Wingo) <florent.xicluna@gmail.com>
* Nicolas Bessi <nicolas.bessi@camptocamp.com>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
* Daniel Reis <dgreis@sapo.pt>
* Holger Brunn <hbrunn@therp.nl>
* Leonardo Pistone <leonardo.pistone@camptocamp.com>
* Adrien Peiffer <adrien.peiffer@acsone.com>
* Thierry Ducrest <thierry.ducrest@camptocamp.com>
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Thomas Binfeld <thomas.binsfeld@acsone.eu>
* Stéphane Bidoul <stefane.bidoul@acsone.com>
* Simone Orsi <simahawk@gmail.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
   :alt: Odoo Community Association
   :target: https://odoo-community.org

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 <https://github.com/OCA/server-env/tree/14.0/server_environment>`_ project on GitHub.

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



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/OCA/server-env",
    "name": "odoo14-addon-server-environment",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Camptocamp,Odoo Community Association (OCA)",
    "author_email": "support@odoo-community.org",
    "download_url": null,
    "platform": null,
    "description": "======================================\nserver configuration environment files\n======================================\n\n.. \n   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n   !! This file is generated by oca-gen-addon-readme !!\n   !! changes will be overwritten.                   !!\n   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n   !! source digest: sha256:e7a36837fb5174b0dc678aa303952274898fe6a9b995b811a7155ac048e19d84\n   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png\n    :target: https://odoo-community.org/page/development-status\n    :alt: Production/Stable\n.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png\n    :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html\n    :alt: License: LGPL-3\n.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github\n    :target: https://github.com/OCA/server-env/tree/14.0/server_environment\n    :alt: OCA/server-env\n.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png\n    :target: https://translation.odoo-community.org/projects/server-env-14-0/server-env-14-0-server_environment\n    :alt: Translate me on Weblate\n.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png\n    :target: https://runboat.odoo-community.org/builds?repo=OCA/server-env&target_branch=14.0\n    :alt: Try me on Runboat\n\n|badge1| |badge2| |badge3| |badge4| |badge5|\n\nThis module provides a way to define an environment in the main Odoo\nconfiguration file and to read some configurations from files\ndepending on the configured environment: you define the environment in\nthe main configuration file, and the values for the various possible\nenvironments are stored in the ``server_environment_files`` companion\nmodule.\n\nThe ``server_environment_files`` module is optional, the values can be set using\nan environment variable with a fallback on default values in the database. you\nwill be able to overwrite some odoo options.\n\nThe configuration read from the files are visible under the Configuration\nmenu.  If you are not in the 'dev' environment you will not be able to\nsee the values contained in the defined secret keys\n(by default : '*passw*', '*key*', '*secret*' and '*token*').\n\n**Table of contents**\n\n.. contents::\n   :local:\n\nInstallation\n============\n\nBy itself, this module does little. See for instance the\n``mail_environment`` addon which depends on this one to allow configuring\nthe incoming and outgoing mail servers depending on the environment.\n\nYou can store your configuration values in a companion module called\n``server_environment_files``. You can copy and customize the provided\n``server_environment_files_sample`` module for this purpose. Alternatively, you\ncan provide them in environment variables ``SERVER_ENV_CONFIG`` and\n``SERVER_ENV_CONFIG_SECRET``.\n\nConfiguration\n=============\n\nTo configure this module, you need to edit the main configuration file\nof your instance, and add a directive called ``running_env``. Commonly\nused values are 'dev', 'test', 'production'::\n\n  [options]\n  running_env=dev\n\nOr set the `RUNNING_ENV` or `ODOO_STAGE` environment variable. If both all are set config file\nwill take the precedence on environment and `RUNNING_ENV` over `ODOO_STAGE`.\n\n`ODOO_STAGE` is used for odoo.sh platform where we can't set `RUNNING_ENV`, possible\nobserved values are `production`, `staging` and `dev`\n\nValues associated to keys containing 'passw' are only displayed in the 'dev'\nenvironment.\n\nIf you don't provide any value, `test` is used as a safe default.\n\nYou have several possibilities to set configuration values:\n\nserver_environment_files\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can edit the settings you need in the ``server_environment_files`` addon. The\n``server_environment_files_sample`` can be used as an example:\n\n* values common to all / most environments can be stored in the\n  ``default/`` directory using the .ini file syntax;\n* each environment you need to define is stored in its own directory\n  and can override or extend default values;\n* you can override or extend values in the main configuration\n  file of your instance;\n* In some platforms (like odoo.sh where production config file is copied to staging)\n  it can be usefull to overwrite options write in the `[options]` section. You must\n  allow the overwrite by adding `server_environment_allow_overwrite_options_section = True``\n  to the former `odoo.cfg` config file or through the environment variable:\n  `export SERVER_ENVIRONMENT_ALLOW_OVERWRITE_OPTIONS_SECTION=True` (if both are set\n  config file take precedent).\n\nEnvironment variable\n~~~~~~~~~~~~~~~~~~~~\n\nYou can define configuration in the environment variable ``SERVER_ENV_CONFIG``\nand/or ``SERVER_ENV_CONFIG_SECRET``. The 2 variables are handled the exact same\nway, this is only a convenience for the deployment where you can isolate the\nsecrets in a different, encrypted, file. They are multi-line environment variables\nin the same configparser format than the files.\nIf you used options in ``server_environment_files``, the options set in the\nenvironment variable override them.\n\nThe options in the environment variable are not dependent of ``running_env``,\nthe content of the variable must be set accordingly to the running environment.\n\nExample of setup:\n\nA public file, containing that will contain public variables::\n\n    # These variables are not odoo standard variables,\n    # they are there to represent what your file could look like\n    export WORKERS='8'\n    export MAX_CRON_THREADS='1'\n    export LOG_LEVEL=info\n    export LOG_HANDLER=\":INFO\"\n    export DB_MAXCONN=5\n\n    # server environment options\n    export SERVER_ENV_CONFIG=\"\n    [storage_backend.my_sftp]\n    sftp_server=10.10.10.10\n    sftp_login=foo\n    sftp_port=22200\n    directory_path=Odoo\n    \"\n\nA second file which is encrypted and contains secrets::\n\n    # This variable is not an odoo standard variable,\n    # it is there to represent what your file could look like\n    export DB_PASSWORD='xxxxxxxxx'\n    # server environment options\n    export SERVER_ENV_CONFIG_SECRET=\"\n    [storage_backend.my_sftp]\n    sftp_password=xxxxxxxxx\n    \"\n\n**WARNING**\n\n  `my_sftp` must match the name of the record.\n  If you want something more reliable use `server.env.techname.mixin`\n  and use `tech_name` field to reference records.\n  See \"USAGE\".\n\n\nDefault values\n~~~~~~~~~~~~~~\n\nWhen using the ``server.env.mixin`` mixin, for each env-computed field, a\ncompanion field ``<field>_env_default`` is created. This field is not\nenvironment-dependent. It's a fallback value used when no key is set in\nconfiguration files / environment variable.\n\nWhen the default field is used, the field is made editable on Odoo.\n\nNote: empty environment keys always take precedence over default fields\n\n\nServer environment integration\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRead the documentation of the class `models/server_env_mixin.py\n<models/server_env_mixin.py>`_.\n\nUsage\n=====\n\nYou can include a mixin in your model and configure the env-computed fields\nby an override of ``_server_env_fields``.\n\n::\n\n    class StorageBackend(models.Model):\n        _name = \"storage.backend\"\n        _inherit = [\"storage.backend\", \"server.env.mixin\"]\n\n        @property\n        def _server_env_fields(self):\n            return {\"directory_path\": {}}\n\nRead the documentation of the class and methods in `models/server_env_mixin.py\n<models/server_env_mixin.py>`__.\n\n\nIf you want to have a technical name to reference::\n\n    class StorageBackend(models.Model):\n        _name = \"storage.backend\"\n        _inherit = [\"storage.backend\", \"server.env.techname.mixin\", \"server.env.mixin\"]\n\n        [...]\n\nKnown issues / Roadmap\n======================\n\n* it is not possible to set the environment from the command line. A\n  configuration file must be used.\n* the module does not allow to set low level attributes such as database server, etc.\n* `server.env.techname.mixin`'s `tech_name` field could leverage the new option\n  for computable / writable fields and get rid of some onchange / read / write code.\n\nBug Tracker\n===========\n\nBugs are tracked on `GitHub Issues <https://github.com/OCA/server-env/issues>`_.\nIn case of trouble, please check there if your issue has already been reported.\nIf you spotted it first, help us to smash it by providing a detailed and welcomed\n`feedback <https://github.com/OCA/server-env/issues/new?body=module:%20server_environment%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.\n\nDo not contact contributors directly about support or help with technical issues.\n\nCredits\n=======\n\nAuthors\n~~~~~~~\n\n* Camptocamp\n\nContributors\n~~~~~~~~~~~~\n\n* Florent Xicluna (Wingo) <florent.xicluna@gmail.com>\n* Nicolas Bessi <nicolas.bessi@camptocamp.com>\n* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>\n* Daniel Reis <dgreis@sapo.pt>\n* Holger Brunn <hbrunn@therp.nl>\n* Leonardo Pistone <leonardo.pistone@camptocamp.com>\n* Adrien Peiffer <adrien.peiffer@acsone.com>\n* Thierry Ducrest <thierry.ducrest@camptocamp.com>\n* Guewen Baconnier <guewen.baconnier@camptocamp.com>\n* Thomas Binfeld <thomas.binsfeld@acsone.eu>\n* St\u00e9phane Bidoul <stefane.bidoul@acsone.com>\n* Simone Orsi <simahawk@gmail.com>\n\nMaintainers\n~~~~~~~~~~~\n\nThis module is maintained by the OCA.\n\n.. image:: https://odoo-community.org/logo.png\n   :alt: Odoo Community Association\n   :target: https://odoo-community.org\n\nOCA, or the Odoo Community Association, is a nonprofit organization whose\nmission is to support the collaborative development of Odoo features and\npromote its widespread use.\n\nThis module is part of the `OCA/server-env <https://github.com/OCA/server-env/tree/14.0/server_environment>`_ project on GitHub.\n\nYou are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.\n\n\n",
    "bugtrack_url": null,
    "license": "LGPL-3",
    "summary": "move some configurations out of the database",
    "version": "14.0.2.2.1",
    "project_urls": {
        "Homepage": "https://github.com/OCA/server-env"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "23b1d7bf4b26ed1f8ad3a8c7628138acf4874ad8be0713ee53acf8a21f2092a3",
                "md5": "badcd24579064232deb7630e5b1ff2d9",
                "sha256": "da81627e153ae25615a8543833959c15907947c93b370243227e569b366d1e6e"
            },
            "downloads": -1,
            "filename": "odoo14_addon_server_environment-14.0.2.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "badcd24579064232deb7630e5b1ff2d9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 189638,
            "upload_time": "2024-03-23T06:50:31",
            "upload_time_iso_8601": "2024-03-23T06:50:31.816491Z",
            "url": "https://files.pythonhosted.org/packages/23/b1/d7bf4b26ed1f8ad3a8c7628138acf4874ad8be0713ee53acf8a21f2092a3/odoo14_addon_server_environment-14.0.2.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-23 06:50:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "OCA",
    "github_project": "server-env",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "cryptography",
            "specs": []
        }
    ],
    "lcname": "odoo14-addon-server-environment"
}
        
Elapsed time: 0.24249s