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
86 changes: 86 additions & 0 deletions mail_partial_autodelete/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
=======================
Mail partial autodelete
=======================

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

.. |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/18.0/mail_partial_autodelete
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-18-0/social-18-0-mail_partial_autodelete
: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=18.0
:alt: Try me on Runboat

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

This module changes what the "autodelete" flag on emails does. These
emails' content is purged, it will not delete them after sending them.
Useful in case you want to keep track of what was sent, but don't want
to store sensitive content that was in the mail body.

**Table of contents**

.. contents::
:local:

Usage
=====

Just install this module and if needed put context key force_autodelete
for emails you don't care about.

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:%20mail_partial_autodelete%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
-------

* Akretion

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

- Kevin Khao <[email protected]>
- Sébastien Beau <[email protected]>

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/18.0/mail_partial_autodelete>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions mail_partial_autodelete/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions mail_partial_autodelete/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2020 Akretion (http://www.akretion.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Mail partial autodelete",
"version": "18.0.1.0.0",
"category": "Generic Modules",
"summary": """ Add functionality to automatically purge body of emails """,
"author": "Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"depends": ["mail"],
"license": "AGPL-3",
"data": [],
"installable": True,
}
1 change: 1 addition & 0 deletions mail_partial_autodelete/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mail_mail
45 changes: 45 additions & 0 deletions mail_partial_autodelete/models/mail_mail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2021 Akretion (http://www.akretion.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import models


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

def _send(
self,
auto_commit=False,
raise_exception=False,
smtp_session=None,
alias_domain_id=False,
mail_server=False,
post_send_callback=None,
):
self = self.with_context(autodelete_skip_unlink=True)
return super()._send(
auto_commit,
raise_exception,
smtp_session,
alias_domain_id,
mail_server,
post_send_callback,
)

def unlink(self):
if self.env.context.get("autodelete_skip_unlink"):
if self.env["ir.config_parameter"].get_param(
"mail_partial_autodelete_debugmode"
):
return self.write({"state": "sent"}) # prevent further operations
# We only want to keep a trace of sent email during a grace period
# exceptions email can be drop
sent_records = self.filtered(lambda s: s.state == "sent")
# we purge (for security reason) email that are not a notification
# maybe we have secret inside
sent_records.filtered(lambda s: not s.is_notification).write(
{"body_html": ""}
)
return super(MailMail, self - sent_records).unlink()
else:
return super().unlink()
3 changes: 3 additions & 0 deletions mail_partial_autodelete/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 mail_partial_autodelete/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Kevin Khao \<[email protected]\>
- Sébastien Beau \<[email protected]\>
4 changes: 4 additions & 0 deletions mail_partial_autodelete/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module changes what the "autodelete" flag on emails does. These
emails' content is purged, it will not delete them after sending them.
Useful in case you want to keep track of what was sent, but don't want
to store sensitive content that was in the mail body.
2 changes: 2 additions & 0 deletions mail_partial_autodelete/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Just install this module and if needed put context key force_autodelete
for emails you don't care about.
Loading