mirror of https://github.com/OCA/social.git
[FIX] mail_tracking_mailgun: bounces error
Since 9a47101964
bouncing the emails through the mailgun controller causes a singleton
error when the anonymous user tries to record the bounce message.
TT44585
pull/1190/head
parent
5f3efe3728
commit
d5ccc794e2
|
@ -8,7 +8,7 @@ from urllib.parse import urljoin
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from odoo import _, api, models
|
from odoo import SUPERUSER_ID, _, api, models
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,6 +35,11 @@ class ResPartner(models.Model):
|
||||||
body = _(
|
body = _(
|
||||||
"Email has been bounced: %(email)s\nReason: %(reason)s\nEvent: %(event_str)s"
|
"Email has been bounced: %(email)s\nReason: %(reason)s\nEvent: %(event_str)s"
|
||||||
) % ({"email": partner.email, "reason": reason, "event_str": event_str})
|
) % ({"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)
|
partner.message_post(body=body)
|
||||||
|
|
||||||
def check_email_validity(self):
|
def check_email_validity(self):
|
||||||
|
|
Loading…
Reference in New Issue