forked from OCA/social
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.0][ADD] mail_tracking addon (OCA#67)
* [ADD] mail_tracking addon * Add description icon * Fixes remarked * Fix Travis error * Remarks fixed
- Loading branch information
Showing
35 changed files
with
3,309 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,112 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
============= | ||
Mail tracking | ||
============= | ||
|
||
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. | ||
|
||
|
||
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_tracking`` | ||
|
||
|
||
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: | ||
|
||
.. |sent| image:: mail_tracking/static/src/img/sent.png | ||
:width: 10px | ||
|
||
.. |delivered| image:: mail_tracking/static/src/img/delivered.png | ||
:width: 15px | ||
|
||
.. |opened| image:: mail_tracking/static/src/img/opened.png | ||
:width: 15px | ||
|
||
.. |error| image:: mail_tracking/static/src/img/error.png | ||
:width: 10px | ||
|
||
.. |waiting| image:: mail_tracking/static/src/img/waiting.png | ||
:width: 10px | ||
|
||
.. |unknown| image:: mail_tracking/static/src/img/unknown.png | ||
:width: 10px | ||
|
||
|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 | ||
|
||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/205/8.0 | ||
|
||
If you want to see all tracking emails and events you can go to | ||
|
||
* Settings > Technical > Email > Tracking emails | ||
* Settings > Technical > Email > Tracking events | ||
|
||
|
||
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 smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
* Thanks to `LlubNek <https://openclipart.org/user-detail/LlubNek>`_ and `Openclipart | ||
<https://openclipart.org>`_ for `the icon | ||
<https://openclipart.org/detail/19342/open-envelope>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Pedro M. Baeza <pedro.baeza@tecnativa.com> | ||
* Antonio Espinosa <antonio.espinosa@tecnativa.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
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,8 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
# flake8: noqa | ||
|
||
from . import models | ||
from . import controllers | ||
from .hooks import post_init_hook |
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,32 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
# 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": "8.0.2.0.0", | ||
"category": "Social Network", | ||
"website": "http://www.tecnativa.com", | ||
"author": "Tecnativa, " | ||
"Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"decimal_precision", | ||
"mail", | ||
], | ||
"data": [ | ||
"data/tracking_data.xml", | ||
"security/ir.model.access.csv", | ||
"views/assets.xml", | ||
"views/mail_tracking_email_view.xml", | ||
"views/mail_tracking_event_view.xml", | ||
"views/res_partner_view.xml", | ||
], | ||
"qweb": [ | ||
"static/src/xml/mail_tracking.xml", | ||
], | ||
"post_init_hook": "post_init_hook", | ||
} |
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,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
# flake8: noqa | ||
|
||
from . import main |
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,86 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import werkzeug | ||
from psycopg2 import OperationalError | ||
from openerp import api, http, registry, SUPERUSER_ID | ||
import logging | ||
_logger = logging.getLogger(__name__) | ||
|
||
BLANK = 'R0lGODlhAQABAIAAANvf7wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==' | ||
|
||
|
||
def _env_get(db): | ||
reg = False | ||
try: | ||
reg = registry(db) | ||
except OperationalError: | ||
_logger.warning("Selected BD '%s' not found", db) | ||
except: # pragma: no cover | ||
_logger.warning("Selected BD '%s' connection error", db) | ||
if reg: | ||
return api.Environment(reg.cursor(), SUPERUSER_ID, {}) | ||
return False | ||
|
||
|
||
class MailTrackingController(http.Controller): | ||
|
||
def _request_metadata(self): | ||
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/all/<string:db>', | ||
type='http', auth='none') | ||
def mail_tracking_all(self, db, **kw): | ||
env = _env_get(db) | ||
if not env: | ||
return 'NOT FOUND' | ||
metadata = self._request_metadata() | ||
response = env['mail.tracking.email'].event_process( | ||
http.request, kw, metadata) | ||
env.cr.commit() | ||
env.cr.close() | ||
return response | ||
|
||
@http.route('/mail/tracking/event/<string:db>/<string:event_type>', | ||
type='http', auth='none') | ||
def mail_tracking_event(self, db, event_type, **kw): | ||
env = _env_get(db) | ||
if not env: | ||
return 'NOT FOUND' | ||
metadata = self._request_metadata() | ||
response = env['mail.tracking.email'].event_process( | ||
http.request, kw, metadata, event_type=event_type) | ||
env.cr.commit() | ||
env.cr.close() | ||
return response | ||
|
||
@http.route('/mail/tracking/open/<string:db>' | ||
'/<int:tracking_email_id>/blank.gif', | ||
type='http', auth='none') | ||
def mail_tracking_open(self, db, tracking_email_id, **kw): | ||
env = _env_get(db) | ||
if env: | ||
tracking_email = env['mail.tracking.email'].search([ | ||
('id', '=', tracking_email_id), | ||
]) | ||
if tracking_email: | ||
metadata = self._request_metadata() | ||
tracking_email.event_create('open', metadata) | ||
else: | ||
_logger.warning( | ||
"MailTracking email '%s' not found", tracking_email_id) | ||
env.cr.commit() | ||
env.cr.close() | ||
|
||
# Always return GIF blank image | ||
response = werkzeug.wrappers.Response() | ||
response.mimetype = 'image/gif' | ||
response.data = BLANK.decode('base64') | ||
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"?> | ||
<!-- © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> | ||
<openerp> | ||
<data> | ||
|
||
<record forcecreate="True" id="decimal_tracking_timestamp" model="decimal.precision"> | ||
<field name="name">MailTracking Timestamp</field> | ||
<field name="digits">6</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
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,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import logging | ||
from openerp import api, SUPERUSER_ID | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def post_init_hook(cr, registry): | ||
with api.Environment.manage(): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
# Recalculate all partner tracking_email_ids | ||
partners = env['res.partner'].search([ | ||
('email', '!=', False), | ||
]) | ||
emails = partners.mapped('email') | ||
_logger.info( | ||
"Recalculating 'tracking_email_ids' in 'res.partner' " | ||
"model for %d email addresses", len(emails)) | ||
for email in emails: | ||
env['mail.tracking.email'].tracking_ids_recalculate( | ||
'res.partner', 'email', 'tracking_email_ids', email) |
Oops, something went wrong.