[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:
@@ -196,7 +196,7 @@ class sale_quote(http.Controller):
|
|||||||
if not tx:
|
if not tx:
|
||||||
tx_id = transaction_obj.create(cr, SUPERUSER_ID, {
|
tx_id = transaction_obj.create(cr, SUPERUSER_ID, {
|
||||||
'acquirer_id': acquirer_id,
|
'acquirer_id': acquirer_id,
|
||||||
'type': 'form',
|
'type': order._get_payment_type(),
|
||||||
'amount': order.amount_total,
|
'amount': order.amount_total,
|
||||||
'currency_id': order.pricelist_id.currency_id.id,
|
'currency_id': order.pricelist_id.currency_id.id,
|
||||||
'partner_id': order.partner_id.id,
|
'partner_id': order.partner_id.id,
|
||||||
@@ -223,7 +223,7 @@ class sale_quote(http.Controller):
|
|||||||
order.pricelist_id.currency_id.id,
|
order.pricelist_id.currency_id.id,
|
||||||
values={
|
values={
|
||||||
'return_url': '/quote/%s/%s' % (order_id, token) if token else '/quote/%s' % order_id,
|
'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.'),
|
'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,
|
'partner_id': order.partner_shipping_id.id or order.partner_invoice_id.id,
|
||||||
'billing_partner_id': order.partner_invoice_id.id,
|
'billing_partner_id': order.partner_invoice_id.id,
|
||||||
|
|||||||
@@ -308,6 +308,8 @@ class sale_order(osv.osv):
|
|||||||
values = dict(template_values, **values)
|
values = dict(template_values, **values)
|
||||||
return super(sale_order, self).create(cr, uid, values, context=context)
|
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):
|
class sale_quote_option(osv.osv):
|
||||||
_name = "sale.quote.option"
|
_name = "sale.quote.option"
|
||||||
|
|||||||
Reference in New Issue
Block a user