From 0c02f4bab5d3c038bce6872e49e60c6805227c0e Mon Sep 17 00:00:00 2001 From: Antonio Espinosa Date: Tue, 10 Oct 2017 11:30:20 +0200 Subject: [PATCH] [FIX] mail_tracking: bugfixes (#199) * [FIX] Only one data-odoo-tracking-email tag in each email * [FIX] Get status even in multicompany instances --- mail_tracking/__manifest__.py | 2 +- mail_tracking/models/ir_mail_server.py | 2 +- mail_tracking/models/mail_message.py | 2 +- mail_tracking/models/mail_tracking_email.py | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mail_tracking/__manifest__.py b/mail_tracking/__manifest__.py index 2581eab133..d9a53b3920 100644 --- a/mail_tracking/__manifest__.py +++ b/mail_tracking/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Email tracking", "summary": "Email tracking system for all mails sent", - "version": "10.0.1.0.0", + "version": "10.0.1.0.1", "category": "Social Network", "website": "http://www.tecnativa.com", "author": "Tecnativa, " diff --git a/mail_tracking/models/ir_mail_server.py b/mail_tracking/models/ir_mail_server.py index 2877d6ce11..f6eae12948 100644 --- a/mail_tracking/models/ir_mail_server.py +++ b/mail_tracking/models/ir_mail_server.py @@ -23,7 +23,7 @@ def _tracking_email_id_body_get(self, body): tracking_email_id = False # https://regex101.com/r/lW4cB1/2 match = re.search( - r']* data-odoo-tracking-email=["\']([0-9]*)["\']', body) + r']*data-odoo-tracking-email=["\']([0-9]*)["\']', body) if match: try: tracking_email_id = int(match.group(1)) diff --git a/mail_tracking/models/mail_message.py b/mail_tracking/models/mail_message.py index 5bd499e071..da24ecce71 100644 --- a/mail_tracking/models/mail_message.py +++ b/mail_tracking/models/mail_message.py @@ -37,7 +37,7 @@ def tracking_status(self): partner_trackings = [] partners_already = self.env['res.partner'] partners = self.env['res.partner'] - trackings = self.env['mail.tracking.email'].search([ + trackings = self.env['mail.tracking.email'].sudo().search([ ('mail_message_id', '=', message.id), ]) # Search all trackings for this message diff --git a/mail_tracking/models/mail_tracking_email.py b/mail_tracking/models/mail_tracking_email.py index 8a51112c5e..a5c00b5981 100644 --- a/mail_tracking/models/mail_tracking_email.py +++ b/mail_tracking/models/mail_tracking_email.py @@ -218,8 +218,12 @@ def tracking_img_add(self, email): self.ensure_one() tracking_url = self._get_mail_tracking_img() if tracking_url: + content = email.get('body', '') + content = re.sub( + r']*data-odoo-tracking-email=["\'][0-9]*["\'][^>]*>', + '', content) body = tools.append_content_to_html( - email.get('body', ''), tracking_url, plaintext=False, + content, tracking_url, plaintext=False, container_tag='div') email['body'] = body return email