[FIX] sale: fix usage of message_post_with_template in batch

Sending confirmation email is generally done on a singleton recordset but
some calls could end up calling in batch. Anyway better safe than sorry.

Task-2710804 (Mail: Clean MailThread API)

closes odoo/odoo#100137

Related: odoo/enterprise#31301
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Thibault Delavallée
2022-09-15 01:23:27 +02:00
parent 3cdc217736
commit 2971dc0a98
+5 -3
View File
@@ -832,9 +832,11 @@ class SaleOrder(models.Model):
# sending mail in sudo was meant for it being sent from superuser
self = self.with_user(SUPERUSER_ID)
mail_template = self._get_confirmation_template()
if mail_template:
self.with_context(force_send=True).message_post_with_template(
for sale_order in self:
mail_template = sale_order._get_confirmation_template()
if not mail_template:
continue
sale_order.with_context(force_send=True).message_post_with_template(
mail_template.id,
composition_mode='comment',
email_layout_xmlid='mail.mail_notification_layout_with_responsible_signature',