-
-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
142 changed files
with
63,473 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,185 @@ | ||
============== | ||
Email tracking | ||
============== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:ea59e8bd25a451ed67c147ccaf3d3959d2530c856358e168205e7aaca19cc415 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/17.0/mail_tracking | ||
:alt: OCA/social | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_tracking | ||
: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=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module shows email notification tracking status for any messages in | ||
mail thread (chatter). Each notified partner will have an intuitive icon | ||
just right to his name. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Installation | ||
============ | ||
|
||
If you're using a multi-database installation (with or without dbfilter | ||
option) where /web/databse/selector returns a list of more than one | ||
database, then you need to add ``mail_tracking`` addon to wide load | ||
addons list (by default, only ``web`` addon), setting ``--load`` option. | ||
For example, ``--load=web,mail,mail_tracking`` | ||
|
||
Configuration | ||
============= | ||
|
||
As there can be scenarios where sending a tracking img in the email body | ||
is not desired, there is a global system parameter | ||
"mail_tracking.tracking_img_disabled" that can be set to True to remove | ||
the tracking img from all outgoing emails. Note that the **Opened** | ||
status will not be available in this case. | ||
|
||
Usage | ||
===== | ||
|
||
When user sends a message in mail_thread (chatter), for instance in | ||
partner form, then an email tracking is created for each email | ||
notification. Then a status icon will appear just right to name of | ||
notified partner. | ||
|
||
These are all available status icons: | ||
|
||
|unknown| **Unknown**: No email tracking info available. Maybe this | ||
notified partner has 'Receive Inbox Notifications by Email' == 'Never' | ||
|
||
|waiting| **Waiting**: Waiting to be sent | ||
|
||
|error| **Error**: Error while sending | ||
|
||
|sent| **Sent**: Sent to SMTP server configured | ||
|
||
|delivered| **Delivered**: Delivered to final MX server | ||
|
||
|opened| **Opened**: Opened by partner | ||
|
||
|cc| **Cc**: It's a Carbon-Copy recipient. Can't know the status so is | ||
'Unknown' | ||
|
||
|noemail| **No Email**: The partner doesn't have a defined email | ||
|
||
|anonuser| **No Partner**: The recipient doesn't have a defined partner | ||
|
||
If you want to see all tracking emails and events you can go to | ||
|
||
- Settings > Technical > Email > Tracking emails | ||
- Settings > Technical > Email > Tracking events | ||
|
||
When the message generates an 'error' status, it will apear on discuss | ||
'Failed' channel. Any view with chatter can show the failed messages | ||
too. | ||
|
||
- Discuss | ||
|
||
|image| | ||
|
||
- Chatter | ||
|
||
|image1| | ||
|
||
You can use "Failed sent messages" filter present in all views to show | ||
records with messages in failed status and that needs an user action. | ||
|
||
- Filter | ||
|
||
|image2| | ||
|
||
.. |unknown| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/src/img/unknown.png | ||
.. |waiting| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/src/img/waiting.png | ||
.. |error| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/src/img/error.png | ||
.. |sent| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/src/img/sent.png | ||
.. |delivered| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/src/img/delivered.png | ||
.. |opened| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/src/img/opened.png | ||
.. |cc| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/src/img/cc.png | ||
.. |noemail| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/src/img/no_email.png | ||
.. |anonuser| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/src/img/anon_user.png | ||
.. |image| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/img/failed_message_discuss.png | ||
.. |image1| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/img/failed_message_widget.png | ||
.. |image2| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_tracking/static/img/failed_message_filter.png | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
- Integrate with the core ``mail.notification`` model as it overlaps | ||
with what the ``mail.tracking`` model does. We could add the existing | ||
features on top of that model and save lots of code lines. | ||
|
||
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_tracking%0Aversion:%2017.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 | ||
------- | ||
|
||
* Tecnativa | ||
|
||
Contributors | ||
------------ | ||
|
||
- `Tecnativa <https://www.tecnativa.com>`__: | ||
|
||
- Pedro M. Baeza | ||
- Antonio Espinosa | ||
- David Vidal | ||
- Ernesto Tejeda | ||
- Rafael Blasco | ||
- Alexandre Díaz | ||
|
||
- `Eezee-IT <https://www.eezee-it.com>`__: | ||
|
||
- Asma Elferkhsi | ||
|
||
- `Vauxoo <https://www.vauxoo.com>`__: | ||
|
||
- Agustín Payen Sandoval | ||
|
||
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/17.0/mail_tracking>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains 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,3 @@ | ||
from . import controllers | ||
from . import models | ||
from . import wizards |
This file contains 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,41 @@ | ||
# Copyright 2016 Tecnativa - Antonio Espinosa | ||
# Copyright 2018 Tecnativa - David Vidal | ||
# Copyright 2018 Tecnativa - Ernesto Tejeda | ||
# Copyright 2019 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Email tracking", | ||
"summary": "Email tracking system for all mails sent", | ||
"version": "17.0.1.0.0", | ||
"category": "Social Network", | ||
"website": "https://github.com/OCA/social", | ||
"author": ("Tecnativa, Odoo Community Association (OCA)"), | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": ["mail"], | ||
"data": [ | ||
"data/tracking_data.xml", | ||
"security/mail_tracking_email_security.xml", | ||
"security/ir.model.access.csv", | ||
"views/mail_tracking_email_view.xml", | ||
"views/mail_tracking_event_view.xml", | ||
"views/mail_message_view.xml", | ||
"views/res_partner_view.xml", | ||
], | ||
"assets": { | ||
"web.assets_backend": [ | ||
"mail_tracking/static/src/core/chatter/*", | ||
"mail_tracking/static/src/core/message/*", | ||
"mail_tracking/static/src/core/search/*", | ||
"mail_tracking/static/src/core/discuss/*", | ||
"mail_tracking/static/src/services/*", | ||
"mail_tracking/static/src/components/message_tracking/*", | ||
"mail_tracking/static/src/components/failed_message/*", | ||
"mail_tracking/static/src/components/failed_message_review/*", | ||
"mail_tracking/static/src/components/failed_messages_panel/*", | ||
], | ||
}, | ||
"demo": ["demo/demo.xml"], | ||
} |
This file contains 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 main | ||
from . import mailbox |
This file contains 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,22 @@ | ||
# Copyright 2024 Tecnativa - David Vidal | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo.http import request, route | ||
|
||
from odoo.addons.mail.controllers.mailbox import MailboxController | ||
|
||
|
||
class MailTrackingMailBoxController(MailboxController): | ||
@route("/mail/failed/messages", methods=["POST"], type="json", auth="user") | ||
def discuss_failed_messages( | ||
self, search_term=None, before=None, after=None, limit=30, around=None | ||
): | ||
"""Fetch failed messages for discuss""" | ||
res = request.env["mail.message"]._message_fetch( | ||
[("is_failed_message", "=", True)], | ||
search_term=search_term, | ||
before=before, | ||
after=after, | ||
around=around, | ||
limit=limit, | ||
) | ||
return {**res, "messages": res["messages"].message_format()} |
This file contains 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,76 @@ | ||
# Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import base64 | ||
import logging | ||
from contextlib import contextmanager | ||
|
||
import werkzeug | ||
|
||
import odoo | ||
from odoo import SUPERUSER_ID, api, http | ||
|
||
from odoo.addons.mail.controllers.mail import MailController | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
BLANK = "R0lGODlhAQABAIAAANvf7wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" | ||
|
||
|
||
@contextmanager | ||
def db_env(dbname): | ||
if not http.db_filter([dbname]): | ||
raise werkzeug.exceptions.BadRequest() | ||
cr = None | ||
if dbname == http.request.db: | ||
cr = http.request.cr | ||
if not cr: | ||
cr = odoo.sql_db.db_connect(dbname).cursor() | ||
yield api.Environment(cr, SUPERUSER_ID, {}) | ||
|
||
|
||
class MailTrackingController(MailController): | ||
def _request_metadata(self): | ||
"""Prepare remote info metadata""" | ||
request = http.request.httprequest | ||
return { | ||
"ip": request.remote_addr or False, | ||
"user_agent": request.user_agent or False, | ||
"os_family": request.user_agent.platform or False, | ||
"ua_family": request.user_agent.browser or False, | ||
} | ||
|
||
@http.route( | ||
[ | ||
"/mail/tracking/open/<string:db>/<int:tracking_email_id>/blank.gif", | ||
"/mail/tracking/open/<string:db>" | ||
"/<int:tracking_email_id>/<string:token>/blank.gif", | ||
], | ||
type="http", | ||
auth="none", | ||
methods=["GET"], | ||
) | ||
def mail_tracking_open(self, db, tracking_email_id, token=False, **kw): | ||
"""Route used to track mail openned (With & Without Token)""" | ||
metadata = self._request_metadata() | ||
with db_env(db) as env: | ||
try: | ||
tracking_email = ( | ||
env["mail.tracking.email"] | ||
.sudo() | ||
.search([("id", "=", tracking_email_id), ("token", "=", token)]) | ||
) | ||
if not tracking_email: | ||
_logger.warning( | ||
"MailTracking email '%s' not found", tracking_email_id | ||
) | ||
elif tracking_email.state in ("sent", "delivered"): | ||
tracking_email.event_create("open", metadata) | ||
except Exception as e: | ||
_logger.warning(e) | ||
|
||
# Always return GIF blank image | ||
response = werkzeug.wrappers.Response() | ||
response.mimetype = "image/gif" | ||
response.data = base64.b64decode(BLANK) | ||
return response |
This file contains 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,13 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> | ||
<odoo> | ||
<record | ||
forcecreate="True" | ||
id="decimal_tracking_timestamp" | ||
model="decimal.precision" | ||
> | ||
<field name="name">MailTracking Timestamp</field> | ||
<field name="digits">6</field> | ||
</record> | ||
</odoo> |
Oops, something went wrong.