diff --git a/addons/payment/controllers/portal.py b/addons/payment/controllers/portal.py index db9aec543a6..4db7e0153ea 100644 --- a/addons/payment/controllers/portal.py +++ b/addons/payment/controllers/portal.py @@ -2,6 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import logging +from unicodedata import normalize import psycopg2 from odoo import http, _ @@ -131,6 +132,7 @@ class WebsitePayment(http.Controller): def pay(self, reference='', order_id=None, amount=False, currency_id=None, acquirer_id=None, **kw): env = request.env user = env.user.sudo() + reference = normalize('NFKD', reference).encode('ascii','ignore').decode('utf-8') # Default values values = { @@ -188,7 +190,7 @@ class WebsitePayment(http.Controller): }) values['acquirers'] = [acq for acq in acquirers if acq.payment_flow in ['form', 's2s']] - values['pms'] = request.env['payment.token'].search([('acquirer_id', 'in', acquirers.filtered(lambda x: x.payment_flow == 's2s').ids)]) + values['pms'] = request.env['payment.token'].search([('acquirer_id', 'in', acquirers.ids)]) return request.render('payment.pay', values) @@ -246,7 +248,7 @@ class WebsitePayment(http.Controller): 'currency_id': int(currency_id), 'partner_id': partner_id, 'payment_token_id': pm_id, - 'type': 'form_save' if token.acquirer_id.save_token != 'none' and partner_id else 'form', + 'type': 'server2server', 'return_url': return_url, } diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js index fdab7ed573f..07432e741b1 100644 --- a/addons/payment/static/src/js/payment_form.js +++ b/addons/payment/static/src/js/payment_form.js @@ -10,6 +10,7 @@ var _t = core._t; publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ selector: '.o_payment_form', events: { + 'submit': 'async payEvent', 'click #o_payment_form_pay': 'async payEvent', 'click #o_payment_form_add_pm': 'addPmEvent', 'click button[name="delete_pm"]': 'deletePmEvent', @@ -21,10 +22,12 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ * @override */ start: function () { - this.options = _.extend(this.$el.data(), this.options); - this.updateNewPaymentDisplayStatus(); - $('[data-toggle="tooltip"]').tooltip(); - return this._super.apply(this, arguments); + var self = this; + return this._super.apply(this, arguments).then(function () { + self.options = _.extend(self.$el.data(), self.options); + self.updateNewPaymentDisplayStatus(); + $('[data-toggle="tooltip"]').tooltip(); + }); }, //-------------------------------------------------------------------------- @@ -147,7 +150,11 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ var form = this.el; var checked_radio = this.$('input[type="radio"]:checked'); var self = this; - var button = ev.target; + if (ev.type === 'submit') { + var button = $(ev.target).find('*[type="submit"]')[0] + } else { + var button = ev.target; + } // first we check that the user has selected a payment method if (checked_radio.length === 1) { diff --git a/addons/payment/views/payment_templates.xml b/addons/payment/views/payment_templates.xml index 6124a77bc87..2de3d8a1faf 100644 --- a/addons/payment/views/payment_templates.xml +++ b/addons/payment/views/payment_templates.xml @@ -152,7 +152,7 @@ Manage your payment methods -