diff --git a/server_environment/README.rst b/server_environment/README.rst
index 0d617513a..58696beb3 100644
--- a/server_environment/README.rst
+++ b/server_environment/README.rst
@@ -71,6 +71,12 @@ 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.
diff --git a/server_environment/readme/CONFIGURE.rst b/server_environment/readme/CONFIGURE.rst
index b3e8024ce..28b91f0c5 100644
--- a/server_environment/readme/CONFIGURE.rst
+++ b/server_environment/readme/CONFIGURE.rst
@@ -5,6 +5,12 @@ 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.
diff --git a/server_environment/server_env.py b/server_environment/server_env.py
index ed16e84ff..ad76e3410 100644
--- a/server_environment/server_env.py
+++ b/server_environment/server_env.py
@@ -45,13 +45,20 @@
def _load_running_env():
if not system_base_config.get("running_env"):
- _logger.info("`running_env` not found. Using default = `test`.")
- _logger.info(
- "We strongly recommend against using the rc file but instead use an "
- "explicit config file or env variable."
- )
- # safe default
- system_base_config["running_env"] = "test"
+ env_running_env = os.environ.get("RUNNING_ENV", os.environ.get("ODOO_STAGE"))
+ if env_running_env:
+ system_base_config["running_env"] = env_running_env
+ else:
+ _logger.info(
+ "`running_env` or `RUNNING_ENV`, `ODOO_STAGE` not found. "
+ "Using default = `test`."
+ )
+ _logger.info(
+ "We strongly recommend against using the rc file but instead use an "
+ "explicit config file or env variable."
+ )
+ # safe default
+ system_base_config["running_env"] = "test"
_load_running_env()
diff --git a/server_environment/static/description/index.html b/server_environment/static/description/index.html
index 873e131f8..d3476ba05 100644
--- a/server_environment/static/description/index.html
+++ b/server_environment/static/description/index.html
@@ -8,10 +8,11 @@
/*
:Author: David Goodger (goodger@python.org)
-:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
+:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
+Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }
-pre.code .ln { color: grey; } /* line numbers */
+pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@
span.pre {
white-space: pre }
-span.problematic {
+span.problematic, pre.problematic {
color: red }
span.section-subtitle {
@@ -423,6 +424,10 @@
[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.
@@ -572,7 +577,9 @@
This module is maintained by the OCA.
-

+
+
+
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.
diff --git a/server_environment/tests/test_server_environment.py b/server_environment/tests/test_server_environment.py
index 714893fe6..cfa6878c9 100644
--- a/server_environment/tests/test_server_environment.py
+++ b/server_environment/tests/test_server_environment.py
@@ -1,6 +1,7 @@
# Copyright 2018 Camptocamp (https://www.camptocamp.com).
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
+import os
from unittest.mock import patch
from odoo.tools.config import config as odoo_config
@@ -37,8 +38,21 @@ def test_default_dev(self):
@patch.dict(odoo_config.options, {"running_env": "whatever"})
def test_default_non_dev_env(self):
+ server_env._load_running_env()
self._test_default(hidden_pwd=True)
+ @patch.dict(odoo_config.options, {"running_env": None})
+ @patch.dict(os.environ, {"RUNNING_ENV": "dev"})
+ def test_default_dev_from_environ(self):
+ server_env._load_running_env()
+ self._test_default()
+
+ @patch.dict(odoo_config.options, {"running_env": None})
+ @patch.dict(os.environ, {"ODOO_STAGE": "dev"})
+ def test_odoosh_dev_from_environ(self):
+ server_env._load_running_env()
+ self._test_default()
+
@patch.dict(odoo_config.options, {"running_env": "testing"})
def test_value_retrival(self):
with self.set_config_dir("testfiles"):