Maintainers
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/iap_mail_domain_blacklist/README.rst b/iap_mail_domain_blacklist/README.rst index d70d264..5e9a504 100644 --- a/iap_mail_domain_blacklist/README.rst +++ b/iap_mail_domain_blacklist/README.rst @@ -31,8 +31,10 @@ IAP Mail Domain BlackList This module allows adding domains to the mail domain blacklist to prevent Odoo from assuming that users with the same domain belong to the same organization. -Due to the nature of this module, in a multi-tenant setting, the configuration in one database -affects all databases in the Odoo instance. +Blacklisted domains are shared across all effective databases on the server. +When the db_name parameter is set, the effective databases are assumed to be the +values of that parameter. If db_name is not set and list_db is true, all +databases on the instance are considered effective databases. **Table of contents** @@ -62,10 +64,12 @@ for the change to take effect. Known issues / Roadmap ====================== -Due to a technical limitation, we cannot use http.db_list() to respect dbfilter -during module loading, as HTTP configuration is not available at that stage. -Therefore, db.list_dbs() is used instead. As a result, blacklist domains from inactive databases -will also affect running databases. +Due to a technical limitation, http.db_list() cannot be used during module +loading to respect dbfilter, because the HTTP layer is not initialized at +that stage. As a result, the module must rely on config.get('db_name') or +db.list_dbs() instead. Consequently, if list_db = True is enabled without +explicitly setting db_name in odoo.conf, blacklist domains from inactive +databases may incorrectly affect active databases. Bug Tracker =========== diff --git a/iap_mail_domain_blacklist/hooks.py b/iap_mail_domain_blacklist/hooks.py index da388b8..c3bb34a 100644 --- a/iap_mail_domain_blacklist/hooks.py +++ b/iap_mail_domain_blacklist/hooks.py @@ -3,8 +3,10 @@ import logging +from odoo.exceptions import AccessDenied from odoo.service import db from odoo.sql_db import db_connect +from odoo.tools import config from odoo.addons.iap.tools import iap_tools @@ -33,8 +35,17 @@ def update_mail_domain_blacklist(cr): iap_tools._MAIL_DOMAIN_BLACKLIST.update(additional_domains) +def _db_names(): + if config.get("db_name"): + return [n.strip() for n in config["db_name"].split(",") if n.strip()] + try: + return db.list_dbs() + except AccessDenied: + return [] + + def post_load_hook(): - for db_name in db.list_dbs(): + for db_name in _db_names(): try: with db_connect(db_name).cursor() as cr: update_mail_domain_blacklist(cr) diff --git a/iap_mail_domain_blacklist/readme/DESCRIPTION.rst b/iap_mail_domain_blacklist/readme/DESCRIPTION.rst index 3987edb..98df39c 100644 --- a/iap_mail_domain_blacklist/readme/DESCRIPTION.rst +++ b/iap_mail_domain_blacklist/readme/DESCRIPTION.rst @@ -1,5 +1,7 @@ This module allows adding domains to the mail domain blacklist to prevent Odoo from assuming that users with the same domain belong to the same organization. -Due to the nature of this module, in a multi-tenant setting, the configuration in one database -affects all databases in the Odoo instance. +Blacklisted domains are shared across all effective databases on the server. +When the db_name parameter is set, the effective databases are assumed to be the +values of that parameter. If db_name is not set and list_db is true, all +databases on the instance are considered effective databases. diff --git a/iap_mail_domain_blacklist/readme/ROADMAP.rst b/iap_mail_domain_blacklist/readme/ROADMAP.rst index 99fecd4..4d8b650 100644 --- a/iap_mail_domain_blacklist/readme/ROADMAP.rst +++ b/iap_mail_domain_blacklist/readme/ROADMAP.rst @@ -1,4 +1,6 @@ -Due to a technical limitation, we cannot use http.db_list() to respect dbfilter -during module loading, as HTTP configuration is not available at that stage. -Therefore, db.list_dbs() is used instead. As a result, blacklist domains from inactive databases -will also affect running databases. +Due to a technical limitation, http.db_list() cannot be used during module +loading to respect dbfilter, because the HTTP layer is not initialized at +that stage. As a result, the module must rely on config.get('db_name') or +db.list_dbs() instead. Consequently, if list_db = True is enabled without +explicitly setting db_name in odoo.conf, blacklist domains from inactive +databases may incorrectly affect active databases. diff --git a/iap_mail_domain_blacklist/static/description/index.html b/iap_mail_domain_blacklist/static/description/index.html index 260635e..ae159ee 100644 --- a/iap_mail_domain_blacklist/static/description/index.html +++ b/iap_mail_domain_blacklist/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 { @@ -371,8 +372,10 @@
This module allows adding domains to the mail domain blacklist to prevent Odoo from assuming that users with the same domain belong to the same organization.
-Due to the nature of this module, in a multi-tenant setting, the configuration in one database -affects all databases in the Odoo instance.
+Blacklisted domains are shared across all effective databases on the server. +When the db_name parameter is set, the effective databases are assumed to be the +values of that parameter. If db_name is not set and list_db is true, all +databases on the instance are considered effective databases.
Table of contents
Due to a technical limitation, we cannot use http.db_list() to respect dbfilter -during module loading, as HTTP configuration is not available at that stage. -Therefore, db.list_dbs() is used instead. As a result, blacklist domains from inactive databases -will also affect running databases.
+Due to a technical limitation, http.db_list() cannot be used during module +loading to respect dbfilter, because the HTTP layer is not initialized at +that stage. As a result, the module must rely on config.get(‘db_name’) or +db.list_dbs() instead. Consequently, if list_db = True is enabled without +explicitly setting db_name in odoo.conf, blacklist domains from inactive +databases may incorrectly affect active databases.
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.