Skip to content
Draft
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
115 changes: 115 additions & 0 deletions iap_mail_domain_blacklist/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
=========================
IAP Mail Domain BlackList
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:32efbaf237a882dc1ba36f3ba442a685dccaa511868f26c2e5662a3332a47d7f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/15.0/iap_mail_domain_blacklist
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-15-0/social-15-0-iap_mail_domain_blacklist
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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.

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**

.. contents::
:local:

Use Cases / Context
===================

Odoo can't add certain domains to the _MAIL_DOMAIN_BLACKLIST, which can result in incorrectly
assuming that users with one of these specific domains belong to the same organization.

For example, since outlook.jp is not part of _MAIL_DOMAIN_BLACKLIST, when partners have this
same domain and create helpdesk tickets, they may end up sharing partners and mistakenly
assuming ownership of each other's tickets.

Configuration
=============

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.

Known issues / Roadmap
======================

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
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
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
`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**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Quartile

Contributors
~~~~~~~~~~~~

* `Quartile <https://www.quartile.co>`_

* Aung Ko Ko Lin
* Yoshi Tashiro

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/social <https://github.com/OCA/social/tree/15.0/iap_mail_domain_blacklist>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions iap_mail_domain_blacklist/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import post_load_hook
17 changes: 17 additions & 0 deletions iap_mail_domain_blacklist/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2025 Quartile
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "IAP Mail Domain BlackList",
"version": "15.0.1.0.0",
"author": "Quartile, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"license": "AGPL-3",
"depends": ["iap"],
"data": [
"data/config_parameter.xml",
"views/res_config_settings_views.xml",
],
"post_load": "post_load_hook",
"installable": True,
}
7 changes: 7 additions & 0 deletions iap_mail_domain_blacklist/data/config_parameter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="param_iap_mail_domain_blacklist" model="ir.config_parameter">
<field name="key">iap_mail_domain_blacklist.mail_domain_blacklist</field>
<field name="value">replace_this_with_real_domains</field>
</record>
</odoo>
53 changes: 53 additions & 0 deletions iap_mail_domain_blacklist/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2025 Quartile
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

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

_logger = logging.getLogger(__name__)


def update_mail_domain_blacklist(cr):
cr.execute(
"""
SELECT EXISTS (
SELECT 1 FROM information_schema.tables
WHERE table_name = 'ir_config_parameter'
)
"""
)
table_exists = cr.fetchone()[0]
if not table_exists:
return
cr.execute(
Comment thread
AungKoKoLin1997 marked this conversation as resolved.
"SELECT value FROM ir_config_parameter WHERE key = %s",
("iap_mail_domain_blacklist.mail_domain_blacklist",),
)
param_value = cr.fetchone()
if param_value and param_value[0]:
additional_domains = {domain.strip() for domain in param_value[0].split(",")}
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_names():
try:
with db_connect(db_name).cursor() as cr:
update_mail_domain_blacklist(cr)
except Exception:
_logger.error(f"Skipping database {db_name} due to an issue connecting.")
1 change: 1 addition & 0 deletions iap_mail_domain_blacklist/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_config_settings
12 changes: 12 additions & 0 deletions iap_mail_domain_blacklist/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Quartile
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

mail_domain_blacklist = fields.Char(
config_parameter="iap_mail_domain_blacklist.mail_domain_blacklist"
)
6 changes: 6 additions & 0 deletions iap_mail_domain_blacklist/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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.
6 changes: 6 additions & 0 deletions iap_mail_domain_blacklist/readme/CONTEXT.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Odoo can't add certain domains to the _MAIL_DOMAIN_BLACKLIST, which can result in incorrectly
assuming that users with one of these specific domains belong to the same organization.

For example, since outlook.jp is not part of _MAIL_DOMAIN_BLACKLIST, when partners have this
same domain and create helpdesk tickets, they may end up sharing partners and mistakenly
assuming ownership of each other's tickets.
4 changes: 4 additions & 0 deletions iap_mail_domain_blacklist/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Quartile <https://www.quartile.co>`_

* Aung Ko Ko Lin
* Yoshi Tashiro
7 changes: 7 additions & 0 deletions iap_mail_domain_blacklist/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +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.

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.
6 changes: 6 additions & 0 deletions iap_mail_domain_blacklist/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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.
Loading
Loading