summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2014-10-09 11:13:30 +0200
committerThibault Delavallée <tde@openerp.com>2014-10-09 12:50:13 +0200
commite9fdc32fba36229d8a85b60abbe72c8dea7730d7 (patch)
tree5c65533d6e0137288496571da93da9b82cea8c00
parentca862e7b852996cb44c444b5725beca8a5d8ae65 (diff)
[IMP] payment, website_sale: better control of sale order confirmation in ecommerce.
Auto confirmation is now controlled by a field on the acquirer that proposes to confirm - at payment (Pay Now button on ecommerce) - at payment confirmation (transaction feedback) - never Also fixed the state of tx for transfer transactions that was modified for debugging in a previous task but not reverted.
-rw-r--r--addons/payment/models/payment_acquirer.py6
-rw-r--r--addons/payment_transfer/models/payment_acquirer.py2
-rw-r--r--addons/website_sale/controllers/main.py5
-rw-r--r--addons/website_sale/models/payment.py2
4 files changed, 13 insertions, 2 deletions
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/<int:sale_order_id>', 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