Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] server_environment from 17.0 #204

Draft
wants to merge 90 commits into
base: 18.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
a07fc2d
[ADD] server evironment file + sample
jgrandguillaume Oct 12, 2011
17e2969
[FIX] openerp\assert_exit_level does not exist ! in server_environment
nbessi Nov 4, 2011
bf22b65
[FIX] typo
nbessi Jan 18, 2012
759d7a1
[FIX] drop the hack for the GTK client, because for 6.1 the web clien…
florentx Mar 5, 2012
b4d3c4d
[MRG] from upstream
Mar 5, 2012
1fee868
[MRG] Fix by florent.x on server_environment: drop the hack for the G…
Oct 23, 2012
627817f
[7.0] mark all unported modules as not installable
gurneyalex Jan 18, 2013
b44c67a
[7.0] 1st pass at porting server_environment
gurneyalex Jan 18, 2013
4810e47
Generate .pot files
Mar 14, 2014
7083994
[PEP8] server_environment
yvaucher Jul 11, 2014
b0addec
move all modules to __unported__ on master branch and set installable…
sbidoul Jul 12, 2014
9012c9c
Moving server environment module and sample module
nbessi Sep 9, 2014
f115489
Port server environment to version 8.0
nbessi Sep 9, 2014
58d905f
[FIX] travis
hbrunn Dec 8, 2014
1cbc4d4
capture stderr as well as stdout when diagnosing
lepistone Feb 5, 2015
a6adc4e
Add license key in __openerp__.py
yvaucher Feb 6, 2015
2bb0a4b
fix pep8 W503
gurneyalex Feb 16, 2015
1de9f54
Add OCA as author of OCA addons
gurneyalex Mar 2, 2015
643b317
Add missing default oca icons
yvaucher Aug 18, 2015
8cda068
[FIX] unconfigured server_environment doesn't play
hbrunn Aug 18, 2015
e275b0f
remove deprecated checks list
lepistone Aug 31, 2015
88bf62c
[UPD] prefix versions with 8.0
sbidoul Oct 9, 2015
54b26a9
[MIG] Make modules uninstallable
pedrobaeza Oct 14, 2015
4008e2c
9.0 migration of server_environment
gurneyalex Jan 21, 2016
4ac862c
[IMP] load server environment options from odoo rcfile too (#556)
sbidoul Sep 26, 2016
6a529fe
[MIG] Make modules uninstallable
pedrobaeza Oct 6, 2016
87e2dd9
[MIG] Rename manifest files
pedrobaeza Oct 6, 2016
2e3ddd4
Migration of server_environment to 10.0
adrienpeiffer Nov 7, 2016
19b5cf6
[MIG] server_environment: Migration to 11.0
TDu Nov 13, 2017
68356dd
server_environment: bump version
sbidoul Mar 30, 2018
bbbf677
[REF] Server Environment: remove dependency on server_environement_files
ThomasBinsfeld Jun 4, 2018
5dc4273
remove obsolete .pot files [ci skip]
sbidoul Jun 15, 2018
b2bc3c2
Add SERVER_ENV_CONFIG to configure vars from env. variable
guewen Jul 19, 2018
f05c431
[REF] Server Environment: restrict access to server config to allowed…
ThomasBinsfeld Oct 8, 2018
547b45f
[MIG] server_environment from 11 to 12
sbidoul Nov 5, 2018
13af908
[MIG] server_environment: Migration to 13.0
grindtildeath Oct 9, 2019
4980c4c
pre-commit, black, isort
sbidoul Oct 12, 2019
1b6f1b1
server_environment: lint fixes after migration
grindtildeath Oct 22, 2019
dd4de68
server-environment: Run pre-commit
grindtildeath Oct 23, 2019
b87b9cf
pre-commit, black, isort
sbidoul Nov 12, 2019
9af1730
[13.0][FIX] server_environment: Change import for Serialized field
rousseldenis Dec 19, 2019
9df937b
Store the 'server.config' fields in sparse fields
guewen Dec 3, 2019
650fc6a
server_environment: Improve tests.common to allow redefinition of ser…
grindtildeath Feb 13, 2020
790631b
server_environment: running_env default to `test` (fix #44)
simahawk Apr 1, 2020
8ef5147
Fix server_environment version
simahawk Jul 3, 2020
e1d6602
Add mixin for tech name
simahawk Jul 15, 2020
0487cd7
Update server_environment/serv_config.py
oscarolar Sep 22, 2020
42877bf
[IMP] : black, isort, prettier
mourad-ehm Oct 12, 2020
1f99468
[MIG] server_environment: Migration to 14.0
mourad-ehm Oct 12, 2020
662566a
Translated using Weblate (French)
sbidoul Dec 13, 2020
08bb66a
Translated using Weblate (Spanish)
Mat-moran Feb 11, 2021
ebf9e88
[UPD] Change LICENSE to LGPL
ivantodorovich Jul 6, 2021
ea5b130
[MIG] server_environment: migration to 15.0
JuMiSanAr Oct 18, 2021
f5f49a0
[FIX] Update server_env_mixin.py to avoid NoneType error
JuMiSanAr Oct 27, 2021
c93fbaf
15.0 server_environment is Production/Stable
gurneyalex Dec 2, 2021
6a91ed7
server_environment: Update default fields label
adrienpeiffer Mar 18, 2022
f0e731d
[IMP] server_environment: black, isort, prettier
FrancoMaxime Sep 1, 2022
6a5d868
[MIG] server_environment: Migration to 16.0
FrancoMaxime Sep 1, 2022
a212c71
Remove required from tech_name mixin
guewen Jan 14, 2021
dbe7daa
server_environment: do not copy tech_name
simahawk May 10, 2022
02d0bf0
[IMP] server_environment: don't print stack trace when the field can'…
ivantodorovich Jul 12, 2022
6b665db
server_env: fix inverse method (closes #151)
simahawk Apr 4, 2023
d6c0f7b
[IMP] Server env default fields string
qgroulard Jun 19, 2023
ff10872
Translated using Weblate (Italian)
francesco-ooops Jun 22, 2023
6101537
Translated using Weblate (Spanish)
Ivorra78 Jul 25, 2023
ae03baa
[FIX] don't use deprecated get_default_locale
sbidoul Aug 28, 2023
2b3eff4
Cache get_serverenvironment()
sbidoul Aug 28, 2023
8047946
Translated using Weblate (Spanish)
Ivorra78 Aug 21, 2023
c0b947a
[IMP] server_environment: pre-commit stuff
moitabenfdz Nov 13, 2023
af8f29c
[MIG] server_environment: Migration to 17.0
moitabenfdz Nov 13, 2023
e59f1b4
[17.0][FIX]server_environment: custom fields must start with x_
moitabenfdz Nov 15, 2023
c2e83ec
[UPD] Update server_environment.pot
Jan 8, 2024
fe8a26a
[BOT] post-merge updates
OCA-git-bot Jan 8, 2024
686eed0
Update translation files
weblate Feb 3, 2024
c58e1c1
Translated using Weblate (Spanish)
Ivorra78 Feb 12, 2024
104304f
Translated using Weblate (Italian)
mymage Feb 14, 2024
31219b7
[UPD] Update server_environment.pot
May 1, 2024
fd5843a
Update translation files
weblate May 1, 2024
9274bd2
Translated using Weblate (Swedish)
jakobkrabbe Jun 12, 2024
4cfc51d
server_environment: Fix value assignation in compute from default
grindtildeath Jun 20, 2024
83acbcc
[BOT] post-merge updates
OCA-git-bot Jun 25, 2024
722df5c
[IMP] server_environment: allow env variable conf
petrus-v Mar 7, 2023
84a7fb8
[FIX] server_environment: compute_default assign
gurneyalex Jun 27, 2024
80e4846
[BOT] post-merge updates
OCA-git-bot Jun 28, 2024
4b13d43
[BOT] post-merge updates
OCA-git-bot Jul 11, 2024
c8c84ee
[TMP] improve xml autoformatting
sbidoul Sep 30, 2024
b2e2cc9
[TMP] ruff.toml fies
sbidoul Sep 30, 2024
6260e87
[IMP] pre-commit autofixes
sbidoul Sep 30, 2024
88522fd
[MIG] server_environment: Migration to 18.0
qgroulard Sep 25, 2024
c3b2f7a
[IMP] README.rst generation
sbidoul Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,13 @@ repos:
- id: oca-checks-odoo-module
- id: oca-checks-po
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: v3.0.3
hooks:
- id: prettier
name: prettier (with plugin-xml)
name: prettier + plugin-xml
additional_dependencies:
- "prettier@2.7.1"
- "@prettier/plugin-xml@2.2.0"
args:
- --plugin=@prettier/plugin-xml
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
- "prettier@3.3.2"
- "@prettier/plugin-xml@3.4.1"
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.11.1
hooks:
Expand Down
12 changes: 12 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('prettier').Config} */
const config = {
plugins: [require.resolve("@prettier/plugin-xml")],
bracketSpacing: false,
printWidth: 88,
proseWrap: "always",
semi: true,
trailingComma: "es5",
xmlWhitespaceSensitivity: "preserve",
};

module.exports = config;
8 changes: 0 additions & 8 deletions .prettierrc.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ exclude = ["setup/*"]
[format]
exclude = ["setup/*"]

[per-file-ignores]
[lint.per-file-ignores]
"__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py
"__manifest__.py" = ["B018"] # useless expression

[isort]
[lint.isort]
section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"]

[isort.sections]
[lint.isort.sections]
"odoo" = ["odoo"]
"odoo-addons" = ["odoo.addons"]

[mccabe]
[lint.mccabe]
max-complexity = 16
271 changes: 271 additions & 0 deletions server_environment/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
======================================
server configuration environment files
======================================

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

.. |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/18.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-18-0/server-env-18-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=18.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.

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;

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:%2018.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/18.0/server_environment>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions server_environment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import models
from . import server_env
from .server_env import serv_config, setboolean
21 changes: 21 additions & 0 deletions server_environment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright Wingo SA
# Copyright 2018 Camptocamp (https://www.camptocamp.com).
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

{
"name": "server configuration environment files",
"version": "18.0.1.0.0",
"depends": ["base", "base_sparse_field"],
"author": "Camptocamp,Odoo Community Association (OCA)",
"summary": "move some configurations out of the database",
"website": "https://github.com/OCA/server-env",
"license": "LGPL-3",
"development_status": "Production/Stable",
"category": "Tools",
"data": [
"security/ir.model.access.csv",
"security/res_groups.xml",
"serv_config.xml",
],
"installable": True,
}
Loading
Loading