diff --git a/server_environment/__manifest__.py b/server_environment/__manifest__.py
index 065af45..e1f1d66 100644
--- a/server_environment/__manifest__.py
+++ b/server_environment/__manifest__.py
@@ -1,33 +1,17 @@
-##############################################################################
-#
-# Adapted by Nicolas Bessi. Copyright Camptocamp SA
-# Based on Florent Xicluna original code. Copyright Wingo SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# Copyright Wingo SA
+# Copyright 2018 Camptocamp (https://www.camptocamp.com).
+# License GPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "server configuration environment files",
- "version": "11.0.2.0.0",
+ "version": "12.0.2.0.0",
"depends": [
"base",
"base_sparse_field",
],
"author": "Camptocamp,Odoo Community Association (OCA)",
"summary": "move some configurations out of the database",
- "website": "http://odoo-community.org/",
+ "website": "http://github.com/OCA/server-env",
"license": "GPL-3 or any later version",
"category": "Tools",
"data": [
diff --git a/server_environment/models/server_env_mixin.py b/server_environment/models/server_env_mixin.py
index bde7b37..cd55277 100644
--- a/server_environment/models/server_env_mixin.py
+++ b/server_environment/models/server_env_mixin.py
@@ -1,5 +1,5 @@
# Copyright 2018 Camptocamp (https://www.camptocamp.com).
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+# License GPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
@@ -97,6 +97,7 @@ class ServerEnvMixin(models.AbstractModel):
"""
_name = 'server.env.mixin'
+ _description = 'Mixin to add server environment in existing models'
server_env_defaults = fields.Serialized()
diff --git a/server_environment/readme/CONFIGURE.rst b/server_environment/readme/CONFIGURE.rst
new file mode 100644
index 0000000..deca37c
--- /dev/null
+++ b/server_environment/readme/CONFIGURE.rst
@@ -0,0 +1,89 @@
+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.
+
+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
+ "
+
+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
+
+
+Keychain integration
+~~~~~~~~~~~~~~~~~~~~
+
+Read the documentation of the class `models/server_env_mixin.py
+`_.
diff --git a/server_environment/readme/CONTRIBUTORS.rst b/server_environment/readme/CONTRIBUTORS.rst
new file mode 100644
index 0000000..4d64e67
--- /dev/null
+++ b/server_environment/readme/CONTRIBUTORS.rst
@@ -0,0 +1,11 @@
+* Florent Xicluna (Wingo)
+* Nicolas Bessi
+* Alexandre Fayolle
+* Daniel Reis
+* Holger Brunn
+* Leonardo Pistone
+* Adrien Peiffer
+* Thierry Ducrest
+* Guewen Baconnier
+* Thomas Binfeld
+* Stéphane Bidoul
diff --git a/server_environment/readme/DESCRIPTION.rst b/server_environment/readme/DESCRIPTION.rst
new file mode 100644
index 0000000..8fc7356
--- /dev/null
+++ b/server_environment/readme/DESCRIPTION.rst
@@ -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/INSTALL.rst b/server_environment/readme/INSTALL.rst
new file mode 100644
index 0000000..8ad360c
--- /dev/null
+++ b/server_environment/readme/INSTALL.rst
@@ -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/ROADMAP.rst b/server_environment/readme/ROADMAP.rst
new file mode 100644
index 0000000..4c8096a
--- /dev/null
+++ b/server_environment/readme/ROADMAP.rst
@@ -0,0 +1,3 @@
+* 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.
diff --git a/server_environment/readme/USAGE.rst b/server_environment/readme/USAGE.rst
new file mode 100644
index 0000000..6c8f221
--- /dev/null
+++ b/server_environment/readme/USAGE.rst
@@ -0,0 +1,15 @@
+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
+`__.
diff --git a/server_environment/serv_config.py b/server_environment/serv_config.py
index e695b99..a18bd22 100644
--- a/server_environment/serv_config.py
+++ b/server_environment/serv_config.py
@@ -153,6 +153,7 @@ class _Defaults(dict):
class ServerConfiguration(models.TransientModel):
"""Display server configuration."""
_name = 'server.config'
+ _description = 'Display server configuration'
_conf_defaults = _Defaults()
@classmethod
diff --git a/server_environment/system_info.py b/server_environment/system_info.py
index 9ccc5bc..6e77f78 100644
--- a/server_environment/system_info.py
+++ b/server_environment/system_info.py
@@ -42,7 +42,7 @@ def get_server_environment():
try:
rev_id = 'bzr: %s' % _get_output('bzr revision-info')
except Exception:
- rev_id = 'Can not retrive revison from git or bzr'
+ rev_id = 'Can not retrieve revison from git or bzr'
os_lang = '.'.join([x for x in locale.getdefaultlocale() if x])
if not os_lang:
diff --git a/server_environment/tests/__init__.py b/server_environment/tests/__init__.py
index 4c7aa90..7309347 100644
--- a/server_environment/tests/__init__.py
+++ b/server_environment/tests/__init__.py
@@ -1,21 +1,2 @@
-##############################################################################
-#
-# Author: Nicolas Bessi
-# Copyright 2014 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
from . import test_server_environment
from . import test_environment_variable
diff --git a/server_environment/tests/common.py b/server_environment/tests/common.py
index ddf1b11..d74a133 100644
--- a/server_environment/tests/common.py
+++ b/server_environment/tests/common.py
@@ -1,5 +1,5 @@
# Copyright 2018 Camptocamp (https://www.camptocamp.com).
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+# License GPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import os
from contextlib import contextmanager
diff --git a/server_environment/tests/test_environment_variable.py b/server_environment/tests/test_environment_variable.py
index 6d29dc5..469bc18 100644
--- a/server_environment/tests/test_environment_variable.py
+++ b/server_environment/tests/test_environment_variable.py
@@ -1,5 +1,5 @@
# Copyright 2018 Camptocamp (https://www.camptocamp.com).
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+# License GPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.addons.server_environment import server_env
diff --git a/server_environment/tests/test_server_environment.py b/server_environment/tests/test_server_environment.py
index 2212a6c..ee33798 100644
--- a/server_environment/tests/test_server_environment.py
+++ b/server_environment/tests/test_server_environment.py
@@ -1,22 +1,5 @@
-##############################################################################
-#
-# Author: Nicolas Bessi
-# Copyright 2014 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# Copyright 2018 Camptocamp (https://www.camptocamp.com).
+# License GPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.addons.server_environment import server_env
from . import common