Merge PR #1190 into 15.0

Signed-off-by pedrobaeza
pull/1196/head
OCA-git-bot 2023-07-26 17:48:38 +00:00
commit c3c9d90062
1 changed files with 6 additions and 1 deletions

View File

@ -8,7 +8,7 @@ from urllib.parse import urljoin
import requests
from odoo import _, api, models
from odoo import SUPERUSER_ID, _, api, models
from odoo.exceptions import UserError
@ -35,6 +35,11 @@ class ResPartner(models.Model):
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):