From 6e97e354d80455f75458aa4f3d802bfb632d9df0 Mon Sep 17 00:00:00 2001 From: "Julien (juc) Castiaux" Date: Tue, 16 Oct 2018 12:33:34 +0000 Subject: [PATCH] [FIX] sale: Wrong email state for order confirmation The email sent after an electronic payment is sent using the quotation template instead of the order template. This PR changes the way payment are done in the backend so the order has the correct state before sending the email. opw-1894258 closes odoo/odoo#27847 --- addons/sale/models/payment.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/sale/models/payment.py b/addons/sale/models/payment.py index 9405adc1e9f..ac5f92df2de 100644 --- a/addons/sale/models/payment.py +++ b/addons/sale/models/payment.py @@ -86,12 +86,10 @@ class PaymentTransaction(models.Model): def _reconcile_after_transaction_done(self): # Override of '_set_transaction_done' in the 'payment' module # to confirm the quotations automatically and to generate the invoices if needed. - sales_orders = self.mapped('sale_order_ids').filtered(lambda so: so.state == 'draft') - sales_orders.force_quotation_send() - sales_orders = self.mapped('sale_order_ids').filtered(lambda so: so.state == 'sent') + sales_orders = self.mapped('sale_order_ids').filtered(lambda so: so.state in ('draft', 'sent')) for so in sales_orders: # For loop because some override of action_confirm are ensure_one. - so.action_confirm() + so.with_context(send_email=True).action_confirm() # invoice the sale orders if needed self._invoice_sale_orders() res = super(PaymentTransaction, self)._reconcile_after_transaction_done()