Skip to content
Open
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
112 changes: 112 additions & 0 deletions base_import_mail_disable/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
========================
Base Import Mail Disable
========================

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

.. |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%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/18.0/base_import_mail_disable
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-base_import_mail_disable
: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/server-tools&target_branch=18.0
:alt: Try me on Runboat

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

This module ensures that Odoo strictly disables outbound emails when
importing massive quantities of data via the standard ``base_import``
wizard.

**Problems it solves:**

- Safeguards the external SMTP queue against badly-coded or third-party
custom modules that might explicitly trigger ``mail.mail.create`` or
``template.send_mail()`` hooks during bulk imports.
- Dynamically intercepts outbound mail in the background and silently
cancels the transmission sequence natively, guaranteeing 100% SMTP
silence during data migrations.

**Table of contents**

.. contents::
:local:

Usage
=====

To verify the functionality of the module:

1. Go to any list view in Odoo (e.g., *Contacts*, *Sales Orders*,
*Users*).
2. Click **Favorites > Import records**.
3. Upload your CSV/Excel file normally.
4. The module operates entirely in the background. It will automatically
intercept the ``model.load()`` operation globally. All explicitly
triggered outbound emails will be routed to the outgoing queue
gracefully as "Cancelled," meaning zero notifications will reach
end-user inboxes.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/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/server-tools/issues/new?body=module:%20base_import_mail_disable%0Aversion:%2018.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
-------

* Heliconia Solutions Pvt. Ltd.

Contributors
------------

- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

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.

.. |maintainer-Bhavesh Heliconia| image:: https://github.com/Bhavesh Heliconia.png?size=40px
:target: https://github.com/Bhavesh Heliconia
:alt: Bhavesh Heliconia

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Bhavesh Heliconia|

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/18.0/base_import_mail_disable>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions base_import_mail_disable/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2026 Heliconia Solutions Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
22 changes: 22 additions & 0 deletions base_import_mail_disable/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2026 Heliconia Solutions Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Base Import Mail Disable",
"summary": "Disables sending of emails and notifications during data imports "
"to avoid flooding",
"version": "18.0.1.0.0",
"category": "Tools",
"website": "https://github.com/OCA/server-tools",
"author": "Heliconia Solutions Pvt. Ltd., Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [
"base_import",
"mail",
],
"data": [],
"maintainers": ["Bhavesh Heliconia"],
"installable": True,
"application": False,
"auto_install": False,
}
4 changes: 4 additions & 0 deletions base_import_mail_disable/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2026 Heliconia Solutions Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import mail_mail
35 changes: 35 additions & 0 deletions base_import_mail_disable/models/mail_mail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2026 Heliconia Solutions Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class MailMail(models.Model):
_inherit = "mail.mail"

@api.model_create_multi
def create(self, values_list):
"""
Intercept hard-coded mail.mail record creations during mass imports.
Instead of letting them queue normally, forcefully flag them as 'cancel'
so the mail cron job inherently ignores them.
"""
if self.env.context.get("import_file"):
for vals in values_list:
vals["state"] = "cancel"
vals["auto_delete"] = False
return super().create(values_list)

def send(self, auto_commit=False, raise_exception=False, post_send_callback=None):
"""
Intercept synchronous/immediate mail dispatch calls during mass imports.
Simulate a successful dispatch by returning True, while protecting the
SMTP server from spam.
"""
if self.env.context.get("import_file"):
return True
return super().send(
auto_commit=auto_commit,
raise_exception=raise_exception,
post_send_callback=post_send_callback,
)
3 changes: 3 additions & 0 deletions base_import_mail_disable/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions base_import_mail_disable/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
- Bhavesh Heliconia
5 changes: 5 additions & 0 deletions base_import_mail_disable/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module ensures that Odoo strictly disables outbound emails when importing massive quantities of data via the standard `base_import` wizard.

**Problems it solves:**
* Safeguards the external SMTP queue against badly-coded or third-party custom modules that might explicitly trigger `mail.mail.create` or `template.send_mail()` hooks during bulk imports.
* Dynamically intercepts outbound mail in the background and silently cancels the transmission sequence natively, guaranteeing 100% SMTP silence during data migrations.
6 changes: 6 additions & 0 deletions base_import_mail_disable/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To verify the functionality of the module:

1. Go to any list view in Odoo (e.g., *Contacts*, *Sales Orders*, *Users*).
2. Click **Favorites > Import records**.
3. Upload your CSV/Excel file normally.
4. The module operates entirely in the background. It will automatically intercept the `model.load()` operation globally. All explicitly triggered outbound emails will be routed to the outgoing queue gracefully as "Cancelled," meaning zero notifications will reach end-user inboxes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading