diff options
| author | Thibault Delavallée <tde@openerp.com> | 2014-05-27 11:34:55 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2014-05-27 11:35:32 +0200 |
| commit | a6379e2e67ffa1436d818fd55f37faed4893a87a (patch) | |
| tree | aba45744e4a6bfc42c787002e71a4cdd4e72078c | |
| parent | ed51e843a20e2fea2b6f4f35527f5629071ff3b1 (diff) | |
[IMP] payment addons: fixed submit buttons: now have type=submit (and not image or nothing) and removed name, because this may cause issues when trying to submit a form manually with type=submit and a name. Also improved js code in website_sale to correctly handle the click binding, the asynchronous call to the server to create the transaction, and then submit the form. As form submission is synchronous in javascript, we cannot use the deferred. Instead we prevent the click event from bubbling, wait for the server to create the transaction, adn then manually submit the form.
| -rw-r--r-- | addons/payment_adyen/views/adyen.xml | 2 | ||||
| -rw-r--r-- | addons/payment_ogone/views/ogone.xml | 2 | ||||
| -rw-r--r-- | addons/payment_paypal/views/paypal.xml | 2 | ||||
| -rw-r--r-- | addons/payment_transfer/views/transfer.xml | 2 | ||||
| -rw-r--r-- | addons/website_sale/static/src/js/website_sale_payment.js | 20 |
5 files changed, 15 insertions, 13 deletions
diff --git a/addons/payment_adyen/views/adyen.xml b/addons/payment_adyen/views/adyen.xml index 75e166f92fe..79281f43a99 100644 --- a/addons/payment_adyen/views/adyen.xml +++ b/addons/payment_adyen/views/adyen.xml @@ -20,7 +20,7 @@ <input t-if="tx_values.get('merchantReturnData')" type='hidden' name='merchantReturnData' t-att-value="tx_values.get('merchantReturnData')"/> <!-- submit --> - <button type="image" name="submit" width="100px" + <button type="submit" width="100px" t-att-class="submit_class"> <img t-if="not submit_txt" src="/payment_adyen/static/src/img/adyen_icon.png"/> <span t-if="submit_txt"><t t-esc="submit_txt"/> <span class="fa fa-long-arrow-right"/></span> diff --git a/addons/payment_ogone/views/ogone.xml b/addons/payment_ogone/views/ogone.xml index be89579c84a..48480da23eb 100644 --- a/addons/payment_ogone/views/ogone.xml +++ b/addons/payment_ogone/views/ogone.xml @@ -41,7 +41,7 @@ <input type='hidden' name='EXCEPTIONURL' t-att-value='tx_values["EXCEPTIONURL"]'/> <input type='hidden' name='CANCELURL' t-att-value='tx_values["CANCELURL"]'/> <!-- submit --> - <button type="image" name="submit" width="100px" + <button type="submit" width="100px" t-att-class="submit_class"> <img t-if="not submit_txt" src="/payment_ogone/static/src/img/ogone_icon.png"/> <span t-if="submit_txt"><t t-esc="submit_txt"/> <span class="fa fa-long-arrow-right"/></span> diff --git a/addons/payment_paypal/views/paypal.xml b/addons/payment_paypal/views/paypal.xml index 3c9ffacf2bf..7a9731c4dfe 100644 --- a/addons/payment_paypal/views/paypal.xml +++ b/addons/payment_paypal/views/paypal.xml @@ -31,7 +31,7 @@ <input t-if="tx_values.get('cancel_return')" type="hidden" name="cancel_return" t-att-value="tx_values.get('cancel_return')"/> <!-- submit --> - <button type="image" name="submit" width="100px" + <button type="submit" width="100px" t-att-class="submit_class"> <img t-if="not submit_txt" src="/payment_paypal/static/src/img/paypal_icon.png"/> <span t-if="submit_txt"><t t-esc="submit_txt"/> <span class="fa fa-long-arrow-right"/></span> diff --git a/addons/payment_transfer/views/transfer.xml b/addons/payment_transfer/views/transfer.xml index ddb45d32e8d..e972677a4a1 100644 --- a/addons/payment_transfer/views/transfer.xml +++ b/addons/payment_transfer/views/transfer.xml @@ -11,7 +11,7 @@ <input type='hidden' name='amount' t-att-value='amount or "0.0"'/> <input type='hidden' name='currency' t-att-value='currency.name'/> <!-- submit --> - <button name="submit" width="100px" + <button type="submit" width="100px" t-att-class="submit_class"> <img t-if="not submit_txt" src="/payment_transfer/static/src/img/transfer_icon.png"/> <span t-if="submit_txt"><t t-esc="submit_txt"/> <span class="fa fa-long-arrow-right"/></span> diff --git a/addons/website_sale/static/src/js/website_sale_payment.js b/addons/website_sale/static/src/js/website_sale_payment.js index d991c86a6b9..d4d4a6712c3 100644 --- a/addons/website_sale/static/src/js/website_sale_payment.js +++ b/addons/website_sale/static/src/js/website_sale_payment.js @@ -10,15 +10,17 @@ $(document).ready(function () { .find("input[name='acquirer']:checked").click(); // When clicking on payment button: create the tx using json then continue to the acquirer - $payment.on("click", "button[name='submit']", function (ev) { - var acquirer_id = $(ev.currentTarget).parents('div.oe_sale_acquirer_button').first().data('id'); - if (! acquirer_id) { - return false; - } - var def = openerp.jsonRpc('/shop/payment/transaction/' + acquirer_id, 'call', {}); - $.when(def).then(function (data) { - return true; - }); + $('button[type="submit"]').on("click", function (ev) { + ev.preventDefault(); + ev.stopPropagation(); + var $form = $(ev.currentTarget).parents('form'); + var acquirer_id = $(ev.currentTarget).parents('div.oe_sale_acquirer_button').first().data('id'); + if (! acquirer_id) { + return false; + } + openerp.jsonRpc('/shop/payment/transaction/' + acquirer_id, 'call', {}).then(function (data) { + $form.submit(); + }); }); }); |
