[14.0][MIG] mail_tracking

This commit is contained in:
simonev 2021-06-25 10:04:21 +02:00 committed by Jasmin Solanki
parent d963b817e4
commit 7f964d9386
7 changed files with 46 additions and 72 deletions

View File

@ -14,13 +14,13 @@ Email tracking
: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/13.0/mail_tracking
:target: https://github.com/OCA/social/tree/14.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-13-0/social-13-0-mail_tracking
:target: https://translation.odoo-community.org/projects/social-14-0/social-14-0-mail_tracking
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/205/13.0
:target: https://runbot.odoo-community.org/runbot/205/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -52,31 +52,31 @@ status icon will appear just right to name of notified partner.
These are all available status icons:
.. |sent| image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/sent.png
.. |sent| image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/sent.png
:width: 10px
.. |delivered| image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/delivered.png
.. |delivered| image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/delivered.png
:width: 15px
.. |opened| image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/opened.png
.. |opened| image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/opened.png
:width: 15px
.. |error| image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/error.png
.. |error| image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/error.png
:width: 10px
.. |waiting| image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/waiting.png
.. |waiting| image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/waiting.png
:width: 10px
.. |unknown| image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/unknown.png
.. |unknown| image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/unknown.png
:width: 10px
.. |cc| image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/cc.png
.. |cc| image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/cc.png
:width: 10px
.. |noemail| image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/no_email.png
.. |noemail| image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/no_email.png
:width: 10px
.. |anonuser| image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/anon_user.png
.. |anonuser| image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/anon_user.png
:width: 10px
|unknown| **Unknown**: No email tracking info available. Maybe this notified partner has 'Receive Inbox Notifications by Email' == 'Never'
@ -109,18 +109,18 @@ too.
* Discuss
.. image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/img/failed_message_discuss.png
.. image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/img/failed_message_discuss.png
* Chatter
.. image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/img/failed_message_widget.png
.. image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/img/failed_message_widget.png
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
.. image:: https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/img/failed_message_filter.png
.. image:: https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/img/failed_message_filter.png
Known issues / Roadmap
======================
@ -133,7 +133,7 @@ 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 <https://github.com/OCA/social/issues/new?body=module:%20mail_tracking%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_tracking%0Aversion:%2014.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.
@ -181,6 +181,6 @@ 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/13.0/mail_tracking>`_ project on GitHub.
This module is part of the `OCA/social <https://github.com/OCA/social/tree/14.0/mail_tracking>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -13,9 +13,7 @@ class IrMailServer(models.Model):
def _tracking_headers_add(self, tracking_email_id, headers):
"""Allow other addons to add its own tracking SMTP headers"""
headers = headers or {}
headers["X-Odoo-Database"] = (
getattr(threading.currentThread(), "dbname", None),
)
headers["X-Odoo-Database"] = getattr(threading.currentThread(), "dbname", None)
headers["X-Odoo-Tracking-ID"] = tracking_email_id
return headers
@ -23,7 +21,7 @@ class IrMailServer(models.Model):
body = body or ""
# https://regex101.com/r/lW4cB1/2
match = re.search(r'<img[^>]*data-odoo-tracking-email=["\']([0-9]*)["\']', body)
return int(match.group(1)) if match and match.group(1) else False
return str(match.group(1)) if match and match.group(1) else False
def build_email(
self,

View File

@ -224,14 +224,13 @@ class MailMessage(models.Model):
return list(filter(_filter_alias, mail_list))
@api.model
def _message_read_dict_postprocess(self, messages, message_tree):
def message_format(self):
"""Preare values to be used by the chatter widget"""
res = super()._message_read_dict_postprocess(messages, message_tree)
mail_message_ids = {m.get("id") for m in messages if m.get("id")}
res = super().message_format()
mail_message_ids = {m.get("id") for m in res if m.get("id")}
mail_messages = self.browse(mail_message_ids)
tracking_statuses = mail_messages.tracking_status()
for message_dict in messages:
for message_dict in res:
mail_message_id = message_dict.get("id", False)
if mail_message_id:
message_dict.update(tracking_statuses[mail_message_id])

View File

@ -6,7 +6,7 @@ from email.utils import getaddresses
from lxml import etree
from odoo import _, api, fields, models
from odoo.tools import email_split_and_format
from odoo.tools import email_split, email_split_and_format
class MailThread(models.AbstractModel):
@ -67,7 +67,7 @@ class MailThread(models.AbstractModel):
partners_info = self._message_partner_info_from_emails(email_extra_list)
for pinfo in partners_info:
partner_id = pinfo["partner_id"]
email = pinfo["full_name"]
email = email_split(pinfo["full_name"])[0].lower()
if not partner_id:
if email not in aliases:
self._message_add_suggested_recipient(

View File

@ -9,6 +9,7 @@ import uuid
from datetime import datetime
from odoo import api, fields, models, tools
from odoo.tools import email_split
_logger = logging.getLogger(__name__)
@ -203,15 +204,10 @@ class MailTrackingEmail(models.Model):
@api.depends("recipient")
def _compute_recipient_address(self):
for email in self:
is_empty_recipient = not email.recipient or "<False>" in email.recipient
if not is_empty_recipient:
matches = re.search(r"<(.*@.*)>", email.recipient)
if matches:
email.recipient_address = matches.group(1).lower()
else:
email.recipient_address = email.recipient.lower()
else:
email.recipient_address = False
recipient_email = email_split(email.recipient)
if recipient_email:
email.recipient_address = recipient_email[0].lower()
@api.depends("name", "recipient")
def _compute_tracking_display_name(self):

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Email tracking</title>
<style type="text/css">
@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/13.0/mail_tracking"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-13-0/social-13-0-mail_tracking"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/14.0/mail_tracking"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-14-0/social-14-0-mail_tracking"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>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.</p>
@ -404,15 +404,15 @@ For example, <tt class="docutils literal"><span class="pre">--load=web,mail_trac
form, then an email tracking is created for each email notification. Then a
status icon will appear just right to name of notified partner.</p>
<p>These are all available status icons:</p>
<p><img alt="unknown" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/unknown.png" style="width: 10px;" /> <strong>Unknown</strong>: No email tracking info available. Maybe this notified partner has Receive Inbox Notifications by Email == Never</p>
<p><img alt="waiting" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/waiting.png" style="width: 10px;" /> <strong>Waiting</strong>: Waiting to be sent</p>
<p><img alt="error" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/error.png" style="width: 10px;" /> <strong>Error</strong>: Error while sending</p>
<p><img alt="sent" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/sent.png" style="width: 10px;" /> <strong>Sent</strong>: Sent to SMTP server configured</p>
<p><img alt="delivered" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/delivered.png" style="width: 15px;" /> <strong>Delivered</strong>: Delivered to final MX server</p>
<p><img alt="opened" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/opened.png" style="width: 15px;" /> <strong>Opened</strong>: Opened by partner</p>
<p><img alt="cc" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/cc.png" style="width: 10px;" /> <strong>Cc</strong>: Its a Carbon-Copy recipient. Cant know the status so is Unknown</p>
<p><img alt="noemail" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/no_email.png" style="width: 10px;" /> <strong>No Email</strong>: The partner doesnt have a defined email</p>
<p><img alt="anonuser" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/src/img/anon_user.png" style="width: 10px;" /> <strong>No Partner</strong>: The recipient doesnt have a defined partner</p>
<p><img alt="unknown" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/unknown.png" style="width: 10px;" /> <strong>Unknown</strong>: No email tracking info available. Maybe this notified partner has Receive Inbox Notifications by Email == Never</p>
<p><img alt="waiting" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/waiting.png" style="width: 10px;" /> <strong>Waiting</strong>: Waiting to be sent</p>
<p><img alt="error" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/error.png" style="width: 10px;" /> <strong>Error</strong>: Error while sending</p>
<p><img alt="sent" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/sent.png" style="width: 10px;" /> <strong>Sent</strong>: Sent to SMTP server configured</p>
<p><img alt="delivered" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/delivered.png" style="width: 15px;" /> <strong>Delivered</strong>: Delivered to final MX server</p>
<p><img alt="opened" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/opened.png" style="width: 15px;" /> <strong>Opened</strong>: Opened by partner</p>
<p><img alt="cc" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/cc.png" style="width: 10px;" /> <strong>Cc</strong>: Its a Carbon-Copy recipient. Cant know the status so is Unknown</p>
<p><img alt="noemail" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/no_email.png" style="width: 10px;" /> <strong>No Email</strong>: The partner doesnt have a defined email</p>
<p><img alt="anonuser" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/src/img/anon_user.png" style="width: 10px;" /> <strong>No Partner</strong>: The recipient doesnt have a defined partner</p>
<p>If you want to see all tracking emails and events you can go to</p>
<ul class="simple">
<li>Settings &gt; Technical &gt; Email &gt; Tracking emails</li>
@ -423,17 +423,17 @@ channel. Any view with chatter can show the failed messages
too.</p>
<ul>
<li><p class="first">Discuss</p>
<img alt="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/img/failed_message_discuss.png" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/img/failed_message_discuss.png" />
<img alt="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/img/failed_message_discuss.png" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/img/failed_message_discuss.png" />
</li>
<li><p class="first">Chatter</p>
<img alt="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/img/failed_message_widget.png" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/img/failed_message_widget.png" />
<img alt="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/img/failed_message_widget.png" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/img/failed_message_widget.png" />
</li>
</ul>
<p>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.</p>
<ul>
<li><p class="first">Filter</p>
<img alt="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/img/failed_message_filter.png" src="https://raw.githubusercontent.com/OCA/social/13.0/mail_tracking/static/img/failed_message_filter.png" />
<img alt="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/img/failed_message_filter.png" src="https://raw.githubusercontent.com/OCA/social/14.0/mail_tracking/static/img/failed_message_filter.png" />
</li>
</ul>
</div>
@ -448,7 +448,7 @@ with messages in failed status and that needs an user action.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_tracking%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_tracking%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -490,7 +490,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/13.0/mail_tracking">OCA/social</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/14.0/mail_tracking">OCA/social</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -7,7 +7,6 @@ import time
import mock
import psycopg2
import psycopg2.errorcodes
from lxml import etree
from odoo import http
from odoo.tests.common import TransactionCase
@ -577,21 +576,3 @@ class TestMailTracking(TransactionCase):
self.assertEqual(b"NONE", none.response[0])
none = controller.mail_tracking_event(db, "open")
self.assertEqual(b"NONE", none.response[0])
class TestMailTrackingViews(TransactionCase):
def test_fields_view_get(self):
result = self.env["res.partner"].fields_view_get(
view_id=self.env.ref("base.view_partner_form").id, view_type="form"
)
doc = etree.XML(result["arch"])
nodes = doc.xpath(
"//field[@name='failed_message_ids'" " and @widget='mail_failed_message']"
)
self.assertTrue(nodes)
result = self.env["res.partner"].fields_view_get(
view_id=self.env.ref("base.view_res_partner_filter").id, view_type="search"
)
doc = etree.XML(result["arch"])
nodes = doc.xpath("//filter[@name='failed_message_ids']")
self.assertTrue(nodes)