summaryrefslogtreecommitdiff
path: root/addons/website_payment/controllers/main.py
diff options
context:
space:
mode:
authorDamien Bouvy <dbo@odoo.com>2015-09-21 12:17:08 +0200
committerDamien Bouvy <dbo@odoo.com>2015-09-21 13:15:58 +0200
commitf89e8f9df2c4ffaafc846082ac2b252c787e1e65 (patch)
tree28d2ebec670ec9ffc93278ddf14c7238ed338cf7 /addons/website_payment/controllers/main.py
parent727f7c417555b90f65b58a07accadc451b53776e (diff)
[IMP] payment, website_sale, website_payment: unique reference on payment no longer prevent paying
Payment transactions referenceis have a unique constraint which was problematic when a payment was cancelled from the acquirer's page. To stick the to DRY principle, I factorized a method that checks for existing references and happens a numerical suffix if necessary. This was already implemented in website_payment but was moved to payment and used in website_sale.
Diffstat (limited to 'addons/website_payment/controllers/main.py')
-rw-r--r--addons/website_payment/controllers/main.py6
1 files changed, 1 insertions, 5 deletions
diff --git a/addons/website_payment/controllers/main.py b/addons/website_payment/controllers/main.py
index 39d659f3b24..13c84313dbd 100644
--- a/addons/website_payment/controllers/main.py
+++ b/addons/website_payment/controllers/main.py
@@ -41,11 +41,7 @@ class website_payment(http.Controller):
acquirer = env['payment.acquirer'].with_context(submit_class='btn btn-primary pull-right',
submit_txt=_('Pay Now')).browse(acquirer_id)
# auto-increment reference with a number suffix if the reference already exists
- ref_suffix = 1
- init_ref = reference
- while request.env['payment.transaction'].sudo().search_count([('reference', '=', reference)]):
- reference = init_ref + '-' + str(ref_suffix)
- ref_suffix += 1
+ reference = request.env['payment.transaction'].get_next_reference(reference)
partner_id = user.partner_id.id if user.partner_id.id != request.website.partner_id.id else False