'website_published': fields.boolean(
'Visible in Portal / Website', copy=False,
help="Make this payment acquirer available (Customer invoices, etc.)"),
+ 'auto_confirm': fields.selection(
+ [('none', 'No automatic confirmation'),
+ ('at_pay_confirm', 'At payment confirmation'),
+ ('at_pay_now', 'At payment')],
+ string='Auto Confirmation', required=True),
# Fees
'fees_active': fields.boolean('Compute fees'),
'fees_dom_fixed': fields.float('Fixed domestic fees'),
'environment': 'test',
'validation': 'automatic',
'website_published': True,
+ 'auto_confirm': 'at_pay_confirm',
}
def _check_required_if_provider(self, cr, uid, ids, context=None):
def _transfer_form_validate(self, cr, uid, tx, data, context=None):
_logger.info('Validated transfer payment for tx %s: set as pending' % (tx.reference))
- return tx.write({'state': 'done'})
+ return tx.write({'state': 'pending'})
'sale_order_id': order.id,
}, context=context)
request.session['sale_transaction_id'] = tx_id
+ tx = transaction_obj.browse(cr, SUPERUSER_ID, tx_id, context=context)
# update quotation
request.registry['sale.order'].write(
'payment_tx_id': request.session['sale_transaction_id']
}, context=context)
+ # confirm the quotation
+ if tx.acquirer_id.auto_confirm == 'at_pay_now':
+ request.registry['sale.order'].action_button_confirm(cr, SUPERUSER_ID, [order.id], context=request.context)
+
return tx_id
@http.route('/shop/payment/get_status/<int:sale_order_id>', type='json', auth="public", website=True)
tx_find_method_name = '_%s_form_get_tx_from_data' % acquirer_name
if hasattr(self, tx_find_method_name):
tx = getattr(self, tx_find_method_name)(cr, uid, data, context=context)
- if tx and tx.state == 'done' and tx.sale_order_id and tx.sale_order_id.state in ['draft', 'sent']:
+ if tx and tx.state == 'done' and tx.auto_confirm == 'at_pay_confirm' and tx.sale_order_id and tx.sale_order_id.state in ['draft', 'sent']:
self.pool['sale.order'].action_button_confirm(cr, SUPERUSER_ID, [tx.sale_order_id.id], context=context)
return res