From 09dbbd77d83332c48f62b1c36c3b33ddbfa3a4eb Mon Sep 17 00:00:00 2001 From: Damien Bouvy <dbo@odoo.com> Date: Fri, 26 Jun 2020 12:37:59 +0000 Subject: [PATCH] [FIX] sale: set and propagate payment type in payment flow The payment.transaction type field allows filtering some potential payment methods down the line of a transaction being created; e.g. if a subscription product is present in a quote, the payment's type should be `form_save` to save the payment token for future use on the subscription that will be created at confirmation. The transaction that got created by sale flows did not set the type of the transaction correctly, and this value was not propagated to the rendering values of the acquirer. It now is. This is necessary as part of task 2275051, where we need to know which payment methods to enable in Stripe depending on a need for tokenization or not (since some methods are not tokenizable). closes odoo/odoo#52855 Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com> --- addons/sale/models/payment.py | 1 + addons/sale/models/sale.py | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/sale/models/payment.py b/addons/sale/models/payment.py index c400e40a9833..fb9806309cc9 100644 --- a/addons/sale/models/payment.py +++ b/addons/sale/models/payment.py @@ -167,6 +167,7 @@ class PaymentTransaction(models.Model): def render_sale_button(self, order, submit_txt=None, render_values=None): values = { 'partner_id': order.partner_id.id, + 'type': self.type, } if render_values: values.update(render_values) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 3d24696afa00..b938dbb2943c 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -911,6 +911,7 @@ class SaleOrder(models.Model): 'currency_id': currency.id, 'partner_id': partner.id, 'sale_order_ids': [(6, 0, self.ids)], + 'type': self[0]._get_payment_type(), }) transaction = self.env['payment.transaction'].create(vals) -- GitLab