[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
This commit is contained in:
Julien (juc) Castiaux
2018-10-17 09:18:49 +00:00
parent 89b15b6d87
commit 6e97e354d8
+2 -4
View File
@@ -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()