Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
62 changes: 30 additions & 32 deletions server_environment/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

======================================
server configuration environment files
======================================
Expand All @@ -17,7 +13,7 @@ server configuration environment files
.. |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/license-LGPL--3-blue.png
.. |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
Expand Down Expand Up @@ -100,12 +96,12 @@ 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
--------------------
Expand Down Expand Up @@ -181,7 +177,9 @@ Server environment integration
------------------------------

Read the documentation of the class
`models/server_env_mixin.py <models/server_env_mixin.py>`__.
`models/server_env_mixin.py <models/server_env_mixin.py>`__ and
[models/server_env_tech_name_mixin.py]
(models/server_env_tech_name_mixin.py)

Usage
=====
Expand All @@ -208,20 +206,20 @@ 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"]
_inherit = ["storage.backend", "server.env.techname.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
===========
Expand All @@ -244,18 +242,18 @@ Authors
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>
- 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
-----------
Expand Down
5 changes: 3 additions & 2 deletions server_environment/models/server_env_tech_name_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ class ServerEnvTechNameMixin(models.AbstractModel):
This mixin helps solve the problem by providing a tech name field
and a cleanup machinery as well as a unique constrain.

To use this mixin add it to the _inherit attr of your module like:
To use this mixin add it to the _inherit attr of your model like:
(instead of `server.env.mixin`)

_inherit = [
"my.model",
"server.env.techname.mixin",
"server.env.mixin",
]

"""

_name = "server.env.techname.mixin"
_inherit = "server.env.mixin"
_description = "Server environment technical name"
_sql_constraints = [
(
Expand Down
3 changes: 2 additions & 1 deletion server_environment/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ 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).
[models/server_env_mixin.py](models/server_env_mixin.py) and [models/server_env_tech_name_mixin.py]
(models/server_env_tech_name_mixin.py)
2 changes: 1 addition & 1 deletion server_environment/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ 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"]
_inherit = ["storage.backend", "server.env.techname.mixin"]

[...]
58 changes: 27 additions & 31 deletions server_environment/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>server configuration environment files</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="server-configuration-environment-files">
<h1 class="title">server configuration environment files</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="server-configuration-environment-files">
<h1>server configuration environment files</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:603faa26be49d7e3b72f509aaf776fff2a2a4593bc444efe2c4abd68c1cb9162
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-env/tree/17.0/server_environment"><img alt="OCA/server-env" src="https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-env-17-0/server-env-17-0-server_environment"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-env&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-env/tree/17.0/server_environment"><img alt="OCA/server-env" src="https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-env-17-0/server-env-17-0-server_environment"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-env&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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
Expand Down Expand Up @@ -410,7 +405,7 @@ <h1>server configuration environment files</h1>
</ul>
</div>
<div class="section" id="installation">
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
<p>By itself, this module does little. See for instance the
<tt class="docutils literal">mail_environment</tt> addon which depends on this one to allow
configuring the incoming and outgoing mail servers depending on the
Expand All @@ -422,7 +417,7 @@ <h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
<tt class="docutils literal">SERVER_ENV_CONFIG</tt> and <tt class="docutils literal">SERVER_ENV_CONFIG_SECRET</tt>.</p>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
<p>To configure this module, you need to edit the main configuration file
of your instance, and add a directive called <tt class="docutils literal">running_env</tt>. Commonly
used values are ‘dev’, ‘test’, ‘production’:</p>
Expand All @@ -441,21 +436,21 @@ <h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
<p>If you don’t provide any value, test is used as a safe default.</p>
<p>You have several possibilities to set configuration values:</p>
<div class="section" id="server-environment-files">
<h3><a class="toc-backref" href="#toc-entry-3">server_environment_files</a></h3>
<h2><a class="toc-backref" href="#toc-entry-3">server_environment_files</a></h2>
<p>You can edit the settings you need in the <tt class="docutils literal">server_environment_files</tt>
addon. The <tt class="docutils literal">server_environment_files_sample</tt> can be used as an
example:</p>
<ul class="simple">
<li>values common to all / most environments can be stored in the
<tt class="docutils literal">default/</tt> directory using the .ini file syntax;</li>
<li>each environment you need to define is stored in its own directory and
can override or extend default values;</li>
<li>each environment you need to define is stored in its own directory
and can override or extend default values;</li>
<li>you can override or extend values in the main configuration file of
your instance;</li>
</ul>
</div>
<div class="section" id="environment-variable">
<h3><a class="toc-backref" href="#toc-entry-4">Environment variable</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">Environment variable</a></h2>
<p>You can define configuration in the environment variable
<tt class="docutils literal">SERVER_ENV_CONFIG</tt> and/or <tt class="docutils literal">SERVER_ENV_CONFIG_SECRET</tt>. The 2
variables are handled the exact same way, this is only a convenience for
Expand Down Expand Up @@ -505,7 +500,7 @@ <h3><a class="toc-backref" href="#toc-entry-4">Environment variable</a></h3>
reference records. See “USAGE”.</blockquote>
</div>
<div class="section" id="default-values">
<h3><a class="toc-backref" href="#toc-entry-5">Default values</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Default values</a></h2>
<p>When using the <tt class="docutils literal">server.env.mixin</tt> mixin, for each env-computed field,
a companion field <tt class="docutils literal">&lt;field&gt;_env_default</tt> is created. This field is not
environment-dependent. It’s a fallback value used when no key is set in
Expand All @@ -514,13 +509,15 @@ <h3><a class="toc-backref" href="#toc-entry-5">Default values</a></h3>
<p>Note: empty environment keys always take precedence over default fields</p>
</div>
<div class="section" id="server-environment-integration">
<h3><a class="toc-backref" href="#toc-entry-6">Server environment integration</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Server environment integration</a></h2>
<p>Read the documentation of the class
<a class="reference external" href="models/server_env_mixin.py">models/server_env_mixin.py</a>.</p>
<a class="reference external" href="models/server_env_mixin.py">models/server_env_mixin.py</a> and
[models/server_env_tech_name_mixin.py]
(models/server_env_tech_name_mixin.py)</p>
</div>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-7">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-7">Usage</a></h1>
<p>You can include a mixin in your model and configure the env-computed
fields by an override of <tt class="docutils literal">_server_env_fields</tt>.</p>
<pre class="literal-block">
Expand All @@ -538,41 +535,41 @@ <h2><a class="toc-backref" href="#toc-entry-7">Usage</a></h2>
<pre class="literal-block">
class StorageBackend(models.Model):
_name = &quot;storage.backend&quot;
_inherit = [&quot;storage.backend&quot;, &quot;server.env.techname.mixin&quot;, &quot;server.env.mixin&quot;]
_inherit = [&quot;storage.backend&quot;, &quot;server.env.techname.mixin&quot;]

[...]
</pre>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-8">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-8">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>it is not possible to set the environment from the command line. A
configuration file must be used.</li>
<li>the module does not allow to set low level attributes such as database
server, etc.</li>
<li>the module does not allow to set low level attributes such as
database server, etc.</li>
<li>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.</li>
option for computable / writable fields and get rid of some onchange
/ read / write code.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-9">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-9">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-env/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/server-env/issues/new?body=module:%20server_environment%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-10">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-10">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-11">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-11">Authors</a></h2>
<ul class="simple">
<li>Camptocamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-12">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-12">Contributors</a></h2>
<ul class="simple">
<li>Florent Xicluna (Wingo) &lt;<a class="reference external" href="mailto:florent.xicluna&#64;gmail.com">florent.xicluna&#64;gmail.com</a>&gt;</li>
<li>Nicolas Bessi &lt;<a class="reference external" href="mailto:nicolas.bessi&#64;camptocamp.com">nicolas.bessi&#64;camptocamp.com</a>&gt;</li>
Expand All @@ -589,7 +586,7 @@ <h3><a class="toc-backref" href="#toc-entry-12">Contributors</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-13">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-13">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -602,6 +599,5 @@ <h3><a class="toc-backref" href="#toc-entry-13">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>