From b12bcfbb1b44cc72cdf73506c540c387f00a37e9 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 4 Nov 2019 12:08:08 +0000 Subject: [PATCH] [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) --- addons/sale/models/sale.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 54b2e1bae8e..dcda7270d15 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -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: