From 57a64bbc8686d96d97015e5fb0c14aa427286114 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 30 May 2018 16:27:49 +0200 Subject: [PATCH] [FIX] website_event: unblock button when no reserve In 11.0, this change e9454e79 solved the use case of: - opening the registration of a ticket - discard => the page must be reloaded to register a ticket A new report is that since 9.0, if we try to register 0 ticket we would also have to reload the page. This commit backports e9454e79 and solves the 0 ticket registration. 10.0 version of 9.0's #24966 opw-1851622 closes #24991 --- addons/website_event/static/src/js/website_event.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/website_event/static/src/js/website_event.js b/addons/website_event/static/src/js/website_event.js index 2038494a3e5..81192b03e0f 100644 --- a/addons/website_event/static/src/js/website_event.js +++ b/addons/website_event/static/src/js/website_event.js @@ -23,16 +23,23 @@ var EventRegistrationForm = Widget.extend({ ev.preventDefault(); ev.stopPropagation(); var $form = $(ev.currentTarget).closest('form'); + var $button = $(ev.currentTarget).closest('[type="submit"]'); var post = {}; $("#registration_form select").each(function() { post[$(this).attr('name')] = $(this).val(); }); return ajax.jsonRpc($form.attr('action'), 'call', post).then(function (modal) { + // Only needed for 9.0 up to saas-14 + if (modal === false) { + $button.prop('disabled', false); + return; + } var $modal = $(modal); $modal.find('.modal-body > div').removeClass('container'); // retrocompatibility - REMOVE ME in master / saas-19 - $modal.after($form).modal(); + $modal.insertAfter($form).modal(); $modal.on('click', '.js_goto_event', function () { $modal.modal('hide'); + $button.prop('disabled', false); }); }); },