diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index d060c8fac14..37a1c4c06ea 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -75,6 +75,11 @@ class PaymentAcquirer(osv.Model): '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'), @@ -88,6 +93,7 @@ class PaymentAcquirer(osv.Model): 'environment': 'test', 'validation': 'automatic', 'website_published': True, + 'auto_confirm': 'at_pay_confirm', } def _check_required_if_provider(self, cr, uid, ids, context=None): diff --git a/addons/payment_transfer/models/payment_acquirer.py b/addons/payment_transfer/models/payment_acquirer.py index 8b8dc7a9649..63883b3df30 100644 --- a/addons/payment_transfer/models/payment_acquirer.py +++ b/addons/payment_transfer/models/payment_acquirer.py @@ -83,4 +83,4 @@ class TransferPaymentTransaction(osv.Model): 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'}) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index d5fcfbbdb79..f7f6c0275dc 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -676,6 +676,7 @@ class website_sale(http.Controller): '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( @@ -684,6 +685,10 @@ class website_sale(http.Controller): '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/', type='json', auth="public", website=True) diff --git a/addons/website_sale/models/payment.py b/addons/website_sale/models/payment.py index 36b681a759b..6ab7e97007f 100644 --- a/addons/website_sale/models/payment.py +++ b/addons/website_sale/models/payment.py @@ -22,7 +22,7 @@ class PaymentTransaction(orm.Model): 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