Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
19 changes: 15 additions & 4 deletions iap_mail_domain_blacklist/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,27 @@ Configuration
2. Search for "Mail Domain Blacklist" and enter the domains you want to blacklist, separated
by commas.

Server configuration
~~~~~~~~~~~~~~~~~~~~~

In the odoo.conf file, set db_list = True to allow listing all databases.
In this case, blacklist domains from all databases will affect every database.
Set db_list = False and explicitly define db_name if you want to load only
the target database. In this case, blacklist domains will affect only that
database.

Note: Every time you update the "Mail Domain Blacklist," you need to restart the Odoo server
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
===========
Expand Down
13 changes: 12 additions & 1 deletion iap_mail_domain_blacklist/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions iap_mail_domain_blacklist/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
1. Go to Settings > General Settings.
2. Search for "Mail Domain Blacklist" and enter the domains you want to blacklist, separated
by commas.

Note: Every time you update the "Mail Domain Blacklist," you need to restart the Odoo server
for the change to take effect.
Comment thread
AungKoKoLin1997 marked this conversation as resolved.
6 changes: 4 additions & 2 deletions iap_mail_domain_blacklist/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
The effect of blacklist domains depends on how the Odoo server is configured to
load databases. In environments where multiple databases can be listed and
accessed, blacklist entries apply across all of them. When the server loads only
a single, explicit database, the blacklist affects only that database.
Comment thread
AungKoKoLin1997 marked this conversation as resolved.
Outdated
10 changes: 6 additions & 4 deletions iap_mail_domain_blacklist/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -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.
58 changes: 37 additions & 21 deletions iap_mail_domain_blacklist/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -377,13 +378,16 @@ <h1 class="title">IAP Mail Domain BlackList</h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#use-cases-context" id="toc-entry-1">Use Cases / Context</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-2">Configuration</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-2">Configuration</a><ul>
<li><a class="reference internal" href="#server-configuration" id="toc-entry-3">Server configuration</a></li>
</ul>
</li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-4">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-5">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-6">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-7">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-8">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-9">Maintainers</a></li>
</ul>
</li>
</ul>
Expand All @@ -403,34 +407,44 @@ <h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
<li>Search for “Mail Domain Blacklist” and enter the domains you want to blacklist, separated
by commas.</li>
</ol>
<div class="section" id="server-configuration">
<h2><a class="toc-backref" href="#toc-entry-3">Server configuration</a></h2>
<p>In the odoo.conf file, set db_list = True to allow listing all databases.
In this case, blacklist domains from all databases will affect every database.
Set db_list = False and explicitly define db_name if you want to load only
the target database. In this case, blacklist domains will affect only that
database.</p>
<p>Note: Every time you update the “Mail Domain Blacklist,” you need to restart the Odoo server
for the change to take effect.</p>
</div>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<p>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.</p>
<h1><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h1>
<p>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.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/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/social/issues/new?body=module:%20iap_mail_domain_blacklist%0Aversion:%2015.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">
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-6">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Authors</a></h2>
<ul class="simple">
<li>Quartile</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.quartile.co">Quartile</a><ul>
<li>Aung Ko Ko Lin</li>
Expand All @@ -440,9 +454,11 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-9">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" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down