diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 5a3dd7d3520..9f6f79dc669 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -404,34 +404,22 @@ class PaymentIcon(models.Model): image = fields.Binary( "Image", attachment=True, help="This field holds the image used for this payment icon, limited to 1024x1024px") - image_medium = fields.Binary( - "Medium-sized image", attachment=True, - help="Medium-sized image of this payment icon. It is automatically " - "resized as a 128x128px image, with aspect ratio preserved. " - "Use this field in form views or some kanban views.") - image_small = fields.Binary( - "Small-sized image", attachment=True, - help="Small-sized image of this payment icon. It is automatically " - "resized as a 64x64px image, with aspect ratio preserved. " - "Use this field anywhere a small image is required.") image_payment_form = fields.Binary( "Image displayed on the payment form", attachment=True) @api.model def create(self, vals): - image_resize_images(vals) - if 'image' in vals: vals['image_payment_form'] = image_resize_image(vals['image'], size=(45,30)) - + vals['image'] = image_resize_image(vals['image'], size=(64,64)) return super(PaymentIcon, self).create(vals) @api.multi def write(self, vals): - image_resize_images(vals) if 'image' in vals: vals['image_payment_form'] = image_resize_image(vals['image'], size=(45,30)) + vals['image'] = image_resize_image(vals['image'], size=(64,64)) return super(PaymentIcon, self).write(vals) class PaymentTransaction(models.Model): diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js index a7197ad1306..491cafcf00c 100644 --- a/addons/payment/static/src/js/payment_form.js +++ b/addons/payment/static/src/js/payment_form.js @@ -18,7 +18,6 @@ odoo.define('payment.payment_form', function (require){ }, payEvent: function(ev) { - // ev.stopPropagation(); ev.preventDefault(); var form = this.el; var checked_radio = this.$('input[type="radio"]:checked'); @@ -113,26 +112,23 @@ odoo.define('payment.payment_form', function (require){ // if there's a prepare tx url set if($tx_url.length == 1) { + // if the user wants to save his credit card info + form_save_token = $('input[name="o_payment_form_save_token"]').checked === true; // then we call the route to prepare the transaction ajax.jsonRpc($tx_url[0].value, 'call', { 'acquirer_id': parseInt(acquirer_id), 'save_token': form_save_token }).then(function(result){ if(result) { - // TBE: I really don't like how it is designed, but I can't do better with how e-commerce works/ - var ignored_inputs = ['data_set', 'o_payment_form_save_token']; - var html_form = ''; - - // we append the form to the body - var form = $(html_form).appendTo("body"); - // we remove the "unused" inputs - for(var i = 0; i < ignored_inputs.length; i++) { - form.find('input[name="' + ignored_inputs[i] + '"]').remove(); - } - // we submit the form - form.submit(); + // if the server sent us the html form, we create a form element + var newForm = document.createElement('form'); + newForm.setAttribute("method", "post"); // set it to post + newForm.setAttribute("action", ds.dataset.actionUrl); // set the action url + newForm.hidden = true; // hide it + newForm.innerHTML = result; // put the html sent by the server inside the form + document.getElementsByTagName('body')[0].appendChild(newForm); // append the form to the body + $(newForm).find('input[data-remove-me]').remove(); // remove all the input that should be removed + newForm.submit(); // and finally submit the form } else { self.error(_t('Server Error'), @@ -146,7 +142,6 @@ odoo.define('payment.payment_form', function (require){ else { // we append the form to the body and send it. - // $(html_form).appendTo("body").submit(); this.error(_t("Cannot set-up the payment"), _t("

We're unable to process your payment.

")); } } @@ -366,11 +361,11 @@ odoo.define('payment.payment_form', function (require){ - $(document).ready(function (){ - if (!$('.o_payment_form').length) { - return $.Deferred().reject("DOM doesn't contain '.o_payment_form'"); - } - var form = new PaymentForm(); - form.attachTo($('.o_payment_form')); - }); + require('web.dom_ready'); // only start this when dom is ready + if (!$('.o_payment_form').length) { + return $.Deferred().reject("DOM doesn't contain '.o_payment_form'"); + } + var form = new PaymentForm(); + form.attachTo($('.o_payment_form')); + }); diff --git a/addons/payment/views/payment_templates.xml b/addons/payment/views/payment_templates.xml index 182a80bf8d7..81e73aa464b 100644 --- a/addons/payment/views/payment_templates.xml +++ b/addons/payment/views/payment_templates.xml @@ -74,7 +74,7 @@ - +
- +
diff --git a/addons/payment/views/payment_views.xml b/addons/payment/views/payment_views.xml index 365a57a7a01..29ab44d606b 100644 --- a/addons/payment/views/payment_views.xml +++ b/addons/payment/views/payment_views.xml @@ -416,6 +416,7 @@ + parent="root_payment_menu" + groups="base.group_no_one"/> diff --git a/addons/payment_adyen/views/payment_adyen_templates.xml b/addons/payment_adyen/views/payment_adyen_templates.xml index 9f0a32deb19..4f4d21811a2 100644 --- a/addons/payment_adyen/views/payment_adyen_templates.xml +++ b/addons/payment_adyen/views/payment_adyen_templates.xml @@ -2,7 +2,7 @@