[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.
This commit is contained in:
Denis Ledoux
2016-04-01 14:50:10 +02:00
parent 845b1bde7b
commit 895e77a336
2 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -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,
+2
View File
@@ -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"