Skip to content

Commit 4d3a1e4

Browse files
[ADD] iap_mail_domain_blacklist
1 parent 4ad2262 commit 4d3a1e4

18 files changed

Lines changed: 744 additions & 0 deletions

File tree

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
=========================
2+
IAP Mail Domain BlackList
3+
=========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:32efbaf237a882dc1ba36f3ba442a685dccaa511868f26c2e5662a3332a47d7f
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
20+
:target: https://github.com/OCA/social/tree/15.0/iap_mail_domain_blacklist
21+
:alt: OCA/social
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/social-15-0/social-15-0-iap_mail_domain_blacklist
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=15.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows adding domains to the mail domain blacklist to prevent Odoo from assuming
32+
that users with the same domain belong to the same organization.
33+
34+
Due to the nature of this module, in a multi-tenant setting, the configuration in one database
35+
affects all databases in the Odoo instance.
36+
37+
**Table of contents**
38+
39+
.. contents::
40+
:local:
41+
42+
Use Cases / Context
43+
===================
44+
45+
Odoo can't add certain domains to the _MAIL_DOMAIN_BLACKLIST, which can result in incorrectly
46+
assuming that users with one of these specific domains belong to the same organization.
47+
48+
For example, since outlook.jp is not part of _MAIL_DOMAIN_BLACKLIST, when partners have this
49+
same domain and create helpdesk tickets, they may end up sharing partners and mistakenly
50+
assuming ownership of each other's tickets.
51+
52+
Configuration
53+
=============
54+
55+
1. Go to Settings > General Settings.
56+
2. Search for "Mail Domain Blacklist" and enter the domains you want to blacklist, separated
57+
by commas.
58+
59+
Note: Every time you update the "Mail Domain Blacklist," you need to restart the Odoo server
60+
for the change to take effect.
61+
62+
Known issues / Roadmap
63+
======================
64+
65+
Due to a technical limitation, we cannot use http.db_list() to respect dbfilter
66+
during module loading, as HTTP configuration is not available at that stage.
67+
Therefore, db.list_dbs() is used instead. As a result, blacklist domains from inactive databases
68+
will also affect running databases.
69+
70+
Bug Tracker
71+
===========
72+
73+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
74+
In case of trouble, please check there if your issue has already been reported.
75+
If you spotted it first, help us to smash it by providing a detailed and welcomed
76+
`feedback <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**>`_.
77+
78+
Do not contact contributors directly about support or help with technical issues.
79+
80+
Credits
81+
=======
82+
83+
Authors
84+
~~~~~~~
85+
86+
* Quartile
87+
88+
Contributors
89+
~~~~~~~~~~~~
90+
91+
* `Quartile <https://www.quartile.co>`_
92+
93+
* Aung Ko Ko Lin
94+
* Yoshi Tashiro
95+
96+
Maintainers
97+
~~~~~~~~~~~
98+
99+
This module is maintained by the OCA.
100+
101+
.. image:: https://odoo-community.org/logo.png
102+
:alt: Odoo Community Association
103+
:target: https://odoo-community.org
104+
105+
OCA, or the Odoo Community Association, is a nonprofit organization whose
106+
mission is to support the collaborative development of Odoo features and
107+
promote its widespread use.
108+
109+
This module is part of the `OCA/social <https://github.com/OCA/social/tree/15.0/iap_mail_domain_blacklist>`_ project on GitHub.
110+
111+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from .hooks import post_load_hook
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2025 Quartile
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
{
5+
"name": "IAP Mail Domain BlackList",
6+
"version": "15.0.1.0.0",
7+
"author": "Quartile, Odoo Community Association (OCA)",
8+
"website": "https://github.com/OCA/social",
9+
"license": "AGPL-3",
10+
"depends": ["iap"],
11+
"data": [
12+
"data/config_parameter.xml",
13+
"views/res_config_settings_views.xml",
14+
],
15+
"post_load": "post_load_hook",
16+
"installable": True,
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="1">
3+
<record id="param_iap_mail_domain_blacklist" model="ir.config_parameter">
4+
<field name="key">iap_mail_domain_blacklist.mail_domain_blacklist</field>
5+
<field name="value">replace_this_with_real_domains</field>
6+
</record>
7+
</odoo>

iap_mail_domain_blacklist/hooks.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2025 Quartile
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
import logging
5+
6+
from odoo.service import db
7+
from odoo.sql_db import db_connect
8+
9+
from odoo.addons.iap.tools import iap_tools
10+
11+
_logger = logging.getLogger(__name__)
12+
13+
14+
def update_mail_domain_blacklist(cr):
15+
cr.execute(
16+
"""
17+
SELECT EXISTS (
18+
SELECT 1 FROM information_schema.tables
19+
WHERE table_name = 'ir_config_parameter'
20+
)
21+
"""
22+
)
23+
table_exists = cr.fetchone()[0]
24+
if not table_exists:
25+
return
26+
cr.execute(
27+
"SELECT value FROM ir_config_parameter WHERE key = %s",
28+
("iap_mail_domain_blacklist.mail_domain_blacklist",),
29+
)
30+
param_value = cr.fetchone()
31+
if param_value and param_value[0]:
32+
additional_domains = {domain.strip() for domain in param_value[0].split(",")}
33+
iap_tools._MAIL_DOMAIN_BLACKLIST.update(additional_domains)
34+
35+
36+
def post_load_hook():
37+
for db_name in db.list_dbs():
38+
try:
39+
with db_connect(db_name).cursor() as cr:
40+
update_mail_domain_blacklist(cr)
41+
except Exception:
42+
_logger.error(f"Skipping database {db_name} due to an issue connecting.")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import res_config_settings
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2025 Quartile
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResConfigSettings(models.TransientModel):
8+
_inherit = "res.config.settings"
9+
10+
mail_domain_blacklist = fields.Char(
11+
config_parameter="iap_mail_domain_blacklist.mail_domain_blacklist"
12+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1. Go to Settings > General Settings.
2+
2. Search for "Mail Domain Blacklist" and enter the domains you want to blacklist, separated
3+
by commas.
4+
5+
Note: Every time you update the "Mail Domain Blacklist," you need to restart the Odoo server
6+
for the change to take effect.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Odoo can't add certain domains to the _MAIL_DOMAIN_BLACKLIST, which can result in incorrectly
2+
assuming that users with one of these specific domains belong to the same organization.
3+
4+
For example, since outlook.jp is not part of _MAIL_DOMAIN_BLACKLIST, when partners have this
5+
same domain and create helpdesk tickets, they may end up sharing partners and mistakenly
6+
assuming ownership of each other's tickets.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* `Quartile <https://www.quartile.co>`_
2+
3+
* Aung Ko Ko Lin
4+
* Yoshi Tashiro

0 commit comments

Comments
 (0)