From 895e77a336a4c6c6766f25cee7eb1a98869ba2af Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 1 Apr 2016 14:47:36 +0200 Subject: [PATCH] [FIX] website_quote: utility method to determine the transaction type of an order The transaction `type` of an order can depend according to the order. For instance, if the order leads to recurring payments, the transaction type became `form_save` instead of `form`. This new method allow to easily override this `type` value for other modules, so the entire button rendering code does not have to be copy/pasted. --- addons/website_quote/controllers/main.py | 4 ++-- addons/website_quote/models/order.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/website_quote/controllers/main.py b/addons/website_quote/controllers/main.py index e78bf64903a..f472cbdfea3 100644 --- a/addons/website_quote/controllers/main.py +++ b/addons/website_quote/controllers/main.py @@ -196,7 +196,7 @@ class sale_quote(http.Controller): if not tx: tx_id = transaction_obj.create(cr, SUPERUSER_ID, { 'acquirer_id': acquirer_id, - 'type': 'form', + 'type': order._get_payment_type(), 'amount': order.amount_total, 'currency_id': order.pricelist_id.currency_id.id, 'partner_id': order.partner_id.id, @@ -223,7 +223,7 @@ class sale_quote(http.Controller): order.pricelist_id.currency_id.id, values={ 'return_url': '/quote/%s/%s' % (order_id, token) if token else '/quote/%s' % order_id, - 'type': 'form', + 'type': order._get_payment_type(), 'alias_usage': _('If we store your payment information on our server, subscription payments will be made automatically.'), 'partner_id': order.partner_shipping_id.id or order.partner_invoice_id.id, 'billing_partner_id': order.partner_invoice_id.id, diff --git a/addons/website_quote/models/order.py b/addons/website_quote/models/order.py index 778617ef5ce..55648f23f03 100644 --- a/addons/website_quote/models/order.py +++ b/addons/website_quote/models/order.py @@ -308,6 +308,8 @@ class sale_order(osv.osv): values = dict(template_values, **values) return super(sale_order, self).create(cr, uid, values, context=context) + def _get_payment_type(self, cr, uid, ids, context=None): + return 'form' class sale_quote_option(osv.osv): _name = "sale.quote.option"