-
-
Notifications
You must be signed in to change notification settings - Fork 712
[15.0][ADD] iap_mail_domain_blacklist #1554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
AungKoKoLin1997
wants to merge
1
commit into
OCA:15.0
Choose a base branch
from
qrtl:15.0-add-iap_mail_domain_blacklis
base: 15.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from . import models | ||
| from .hooks import post_load_hook |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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( | ||
| "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.") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import res_config_settings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.