From 317266d4e3796dfd1d759c62e02a8cd47e5ab1a2 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Thu, 5 Nov 2020 14:47:28 +0000 Subject: [PATCH] [IMP] payment, payment_test: missing payment token identifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit payment tokens had no name for Test Payment Acquirer After this commit tokens generated by Test Payment Acquirer have a name that combines the last 4 digits of the card number and the card account holder name https://github.com/odoo/odoo/issues/50965 closes odoo/odoo#61848 X-original-commit: e20f0650acbd1a7a918375a70ec5c89606523a7b Signed-off-by: Jérémy Kersten (jke) --- addons/payment/i18n/payment.pot | 4 ++-- addons/payment/static/src/js/payment_form.js | 8 ++++---- addons/payment_test/models/payment_acquirer.py | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/payment/i18n/payment.pot b/addons/payment/i18n/payment.pot index d7e1342de6d..22e7462ce17 100644 --- a/addons/payment/i18n/payment.pot +++ b/addons/payment/i18n/payment.pot @@ -101,7 +101,7 @@ msgstr "" #. openerp-web #: code:addons/payment/static/src/js/payment_form.js:0 #, python-format -msgid "

This card is currently linked to the following records:

" +msgid "This card is currently linked to the following records:" msgstr "" #. module: payment @@ -1926,7 +1926,7 @@ msgstr "" #. openerp-web #: code:addons/payment/static/src/js/payment_form.js:0 #, python-format -msgid "We are not able to add your payment method at the moment.

" +msgid "We are not able to add your payment method at the moment." msgstr "" #. module: payment diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js index e8d6d784cea..59ae4b0e826 100644 --- a/addons/payment/static/src/js/payment_form.js +++ b/addons/payment/static/src/js/payment_form.js @@ -63,7 +63,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ this.$('#payment_error').remove(); var messageResult = '
'; if (title != '') { - messageResult = messageResult + '' + _.str.escapeHTML(title) + ':
'; + messageResult = messageResult + '' + _.str.escapeHTML(title) + ':
'; } messageResult = messageResult + _.str.escapeHTML(message) + '
'; $acquirerForm.append(messageResult); @@ -448,7 +448,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ self.displayError( _t('Server error'), - _t("We are not able to add your payment method at the moment.

") + + _t("We are not able to add your payment method at the moment.") + self._parseError(error) ); }); @@ -517,10 +517,10 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ // if there's records linked to this payment method var content = ''; result[pm_id].forEach(function (sub) { - content += '

' + sub.name + '

'; + content += '

' + sub.name + '

'; }); - content = $('
').html(_t('

This card is currently linked to the following records:

') + content); + content = $('

').html('

' + _t('This card is currently linked to the following records:') + '

' + content); // Then we display the list of the records and ask the user if he really want to remove the payment method. new Dialog(self, { title: _t('Warning!'), diff --git a/addons/payment_test/models/payment_acquirer.py b/addons/payment_test/models/payment_acquirer.py index c569c7a1f07..b9eafcb6f73 100644 --- a/addons/payment_test/models/payment_acquirer.py +++ b/addons/payment_test/models/payment_acquirer.py @@ -31,7 +31,8 @@ class PaymentAcquirerTest(models.Model): payment_token = self.env['payment.token'].sudo().create({ 'acquirer_ref': uuid4(), 'acquirer_id': int(data['acquirer_id']), - 'partner_id': int(data['partner_id']) + 'partner_id': int(data['partner_id']), + 'name': 'XXXXXXXXXXXX%s - %s' % (data['cc_number'][-4:], data['cc_holder_name']) }) return payment_token