Skip to content

Commit

Permalink
[FIX] mail_tracking_mailgun: bounces error
Browse files Browse the repository at this point in the history
Since odoo/odoo@9a47101
bouncing the emails through the mailgun controller causes a singleton
error when the anonymous user tries to record the bounce message.

TT44585
  • Loading branch information
chienandalu committed Jul 26, 2023
1 parent 5f3efe3 commit d5ccc79
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mail_tracking_mailgun/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import requests

from odoo import _, api, models
from odoo import SUPERUSER_ID, _, api, models
from odoo.exceptions import UserError


Expand All @@ -35,6 +35,11 @@ def _email_bounced_set(self, reason, event):
body = _(
"Email has been bounced: %(email)s\nReason: %(reason)s\nEvent: %(event_str)s"
) % ({"email": partner.email, "reason": reason, "event_str": event_str})
# This function can be called by the non user via the callback_method set in
# /mail/tracking/mailgun/all/. A sudo() is not enough to succesfully send
# the bounce message in this circumstances.
if self.env.su:
partner = partner.with_user(SUPERUSER_ID)
partner.message_post(body=body)

def check_email_validity(self):
Expand Down

0 comments on commit d5ccc79

Please sign in to comment.