[FIX] sale: have sender in SO confirmation email

Before 13.0 .sudo() before sending a mail would send it as superuser user
(which was the intention in this case), but since 13.0 for the same
intention we need .with_user(SUPERUSER_ID).

Without this change, the confirmation email on a sale order would have
no sender ending up in failure.

opw-2118612
closes #39737

closes odoo/odoo#39752

X-original-commit: 6aebb5231c3ed0b87cdddcd9cb463952e346ec07
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
Nicolas Lempereur
2019-11-04 14:18:16 +00:00
committed by fw-bot
parent c4a339e839
commit b12bcfbb1b
+4 -1
View File
@@ -5,7 +5,7 @@ from datetime import datetime, timedelta
from functools import partial
from itertools import groupby
from odoo import api, fields, models, _
from odoo import api, fields, models, SUPERUSER_ID, _
from odoo.exceptions import UserError, ValidationError
from odoo.tools.misc import formatLang
from odoo.osv import expression
@@ -698,6 +698,9 @@ class SaleOrder(models.Model):
return super(SaleOrder, self.with_context(mail_post_autofollow=True)).message_post(**kwargs)
def _send_order_confirmation_mail(self):
if self.env.su:
# sending mail in sudo was meant for it being sent from superuser
self = self.with_user(SUPERUSER_ID)
template_id = self._find_mail_template(force_confirmation_template=True)
if template_id:
for order in self: