diff --git a/addons/payment/security/ir.model.access.csv b/addons/payment/security/ir.model.access.csv index 2bfa46839a0..f1d86956349 100644 --- a/addons/payment/security/ir.model.access.csv +++ b/addons/payment/security/ir.model.access.csv @@ -9,3 +9,6 @@ payment_method_all,payment.token.all,model_payment_token,,1,0,0,0 payment_method_user,payment.token.user,model_payment_token,base.group_user,1,1,1,1 payment_method_portal,payment.token.portal,model_payment_token,base.group_portal,1,1,1,1 payment_method_system,payment.token.system,model_payment_token,base.group_system,1,1,1,1 +payment_option_all,payment.option.all,model_payment_option,,1,0,0,0 +payment_option_user,payment.option.user,model_payment_option,base.group_user,1,1,1,0 +payment_option_system,payment.option.system,model_payment_option,base.group_system,1,1,1,1 \ No newline at end of file diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js index ae2d44c1cb7..bf8f490a493 100644 --- a/addons/payment/static/src/js/payment_form.js +++ b/addons/payment/static/src/js/payment_form.js @@ -59,7 +59,7 @@ odoo.define('payment.payment_form', function (require){ } // if the server has returned false, we display an error else { - self.error(_t('Error'), + self.error(_t('Server Error'), _t("
We are not able to add your payment method at the moment.
")); } // here we remove the 'processing' icon from the 'add a new payment' button @@ -70,10 +70,31 @@ odoo.define('payment.payment_form', function (require){ $(button).attr('disabled', false); $(button).find('span.o_loader').remove(); - self.error(_t('Error'), + self.error(_t('Server Error'), _t("We are not able to add your payment method at the moment.
") + (core.debug ? data.data.message : '')); }); } + // if the user is going to pay with a form payment, then + else if(this.isFormPaymentRadio(checked_radio)) + { + // we retrieve the acquirer id and its form + var acquirer_id = this.getAcquirerIdFromRadio(checked_radio); + var acquirer_form = this.$('#o_payment_form_acq_' + acquirer_id); + var inputs_form = $('input', acquirer_form); + var ds = $('input[name="data_set"]', acquirer_form)[0]; + + // Here we take the values we need to send to the acquirer and generate a form with them + var html_form = ''; + // we append the form to the body and send it. + $(html_form).appendTo("body").submit(); + } // if the user is using an old payment else { // then we just submit the form @@ -81,8 +102,8 @@ odoo.define('payment.payment_form', function (require){ } } else { - this.error(_t('Error'), - _t('Please select a payment method
')); + this.error(_t('No payment method selected'), + _t('Please select a payment method.
')); } }, // event handler when clicking on the button to add a new payment method @@ -132,7 +153,7 @@ odoo.define('payment.payment_form', function (require){ } // if the server has returned false, we display an error else { - self.error(_t('Error'), + self.error(_t('Server Error'), _t("We are not able to add your payment method at the moment.
")); } // here we remove the 'processing' icon from the 'add a new payment' button @@ -143,13 +164,13 @@ odoo.define('payment.payment_form', function (require){ $(button).attr('disabled', false); $(button).find('span.o_loader').remove(); - self.error(_t('Error'), + self.error(_t('Server error'), _t("We are not able to add your payment method at the moment.
") + (core.debug ? data.data.message : '')); }); } else { - this.error(_t('Error'), - _t('Please select the option to add a new payment method
')); + this.error(_t('No payment method selected'), + _t('Please select the option to add a new payment method.
')); } }, // event handler when clicking on a button to delete a payment method @@ -170,7 +191,7 @@ odoo.define('payment.payment_form', function (require){ ev.target.closest('div').remove(); } },function(type,err){ - self.error(_t('Error'), + self.error(_t('Server Error'), _t("We are not able to delete your payment method at the moment.
")); }); }; @@ -202,7 +223,7 @@ odoo.define('payment.payment_form', function (require){ Delete(); } }, function(type, err){ - self.error(_t('Error'), + self.error(_t('Server Error'), _t("We are not able to delete your payment method at the moment.
") + (core.debug ? err.data.message : '')); }); }, @@ -215,28 +236,43 @@ odoo.define('payment.payment_form', function (require){ var checked_radio = this.$('input[type="radio"]:checked'); // we hide all the acquirers form this.$('[id*="o_payment_add_token_acq_"]').addClass('hidden'); + this.$('[id*="o_payment_form_acq_"]').addClass('hidden'); + if(checked_radio.length != 1) { + return; + } + checked_radio = checked_radio[0]; // if we clicked on an add new payment radio - if(checked_radio.length == 1 && this.isNewPaymentRadio(checked_radio[0])) + if(this.isNewPaymentRadio(checked_radio)) { // then we retrieve the acquirer name - var acquirer_id = this.getAcquirerIdFromRadio(checked_radio[0]); + var acquirer_id = this.getAcquirerIdFromRadio(checked_radio); // and display its form this.$('#o_payment_add_token_acq_' + acquirer_id).removeClass('hidden'); } + else if(this.isFormPaymentRadio(checked_radio)) + { + // then we retrieve the acquirer name + var acquirer_id = this.getAcquirerIdFromRadio(checked_radio); + // and display its form + this.$('#o_payment_form_acq_' + acquirer_id).removeClass('hidden'); + } }, isNewPaymentRadio: function(element) { - return $(element).data('acquirer-id') !== undefined; + return $(element).data('s2s-payment') === 'True'; + }, + isFormPaymentRadio: function(element) { + return $(element).data('form-payment') === 'True'; }, getAcquirerIdFromRadio: function(element) { return $(element).data('acquirer-id'); }, error: function(title, message, url) { return new Dialog(null, { - title: title || "", - $content: $(core.qweb.render('website.error_dialog', { - message: message || "", - })), - }).open(); + title: _t('Error: ') + title, + size: 'medium', + $content: message || "", + buttons: [ + {text: _t('Ok'), close: true}]}).open(); }, getFormData: function($form){ var unindexed_array = $form.serializeArray(); diff --git a/addons/payment/views/payment_portal_templates.xml b/addons/payment/views/payment_portal_templates.xml index 3c8a5e3f5d3..f599329e5e1 100644 --- a/addons/payment/views/payment_portal_templates.xml +++ b/addons/payment/views/payment_portal_templates.xml @@ -19,6 +19,7 @@