diff --git a/mail_tracking/README.rst b/mail_tracking/README.rst index d37ee6b..66e5dcf 100644 --- a/mail_tracking/README.rst +++ b/mail_tracking/README.rst @@ -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 `_. 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 `_. +`feedback `_. 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 `_ project on GitHub. +This module is part of the `OCA/social `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_tracking/models/ir_mail_server.py b/mail_tracking/models/ir_mail_server.py index 46d404c..769b6bd 100644 --- a/mail_tracking/models/ir_mail_server.py +++ b/mail_tracking/models/ir_mail_server.py @@ -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']*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, diff --git a/mail_tracking/models/mail_message.py b/mail_tracking/models/mail_message.py index c50e77b..fc6cc67 100644 --- a/mail_tracking/models/mail_message.py +++ b/mail_tracking/models/mail_message.py @@ -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]) diff --git a/mail_tracking/models/mail_thread.py b/mail_tracking/models/mail_thread.py index 6793ec9..a18478f 100644 --- a/mail_tracking/models/mail_thread.py +++ b/mail_tracking/models/mail_thread.py @@ -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( diff --git a/mail_tracking/models/mail_tracking_email.py b/mail_tracking/models/mail_tracking_email.py index aa7e1c2..e678033 100644 --- a/mail_tracking/models/mail_tracking_email.py +++ b/mail_tracking/models/mail_tracking_email.py @@ -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 "" 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 + 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): diff --git a/mail_tracking/static/description/index.html b/mail_tracking/static/description/index.html index 61f9ec0..35df0e4 100644 --- a/mail_tracking/static/description/index.html +++ b/mail_tracking/static/description/index.html @@ -3,7 +3,7 @@ - + Email tracking