Skip to content

Commit

Permalink
[FIX] mail_tracking: bugfixes (OCA#199)
Browse files Browse the repository at this point in the history
* [FIX] Only one data-odoo-tracking-email tag in each email
* [FIX] Get status even in multicompany instances
  • Loading branch information
antespi authored and ernestotejeda committed Dec 18, 2018
1 parent 0994ada commit 0c02f4b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mail_tracking/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "
Expand Down
2 changes: 1 addition & 1 deletion mail_tracking/models/ir_mail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'<img [^>]* data-odoo-tracking-email=["\']([0-9]*)["\']', body)
r'<img[^>]*data-odoo-tracking-email=["\']([0-9]*)["\']', body)
if match:
try:
tracking_email_id = int(match.group(1))
Expand Down
2 changes: 1 addition & 1 deletion mail_tracking/models/mail_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion mail_tracking/models/mail_tracking_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'<img[^>]*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
Expand Down

0 comments on commit 0c02f4b

Please sign in to comment.