From f7917b1502e361701c22899227c5bdbb1cda4565 Mon Sep 17 00:00:00 2001 From: Vincent Schippefilt Date: Wed, 6 Mar 2019 14:02:35 +0100 Subject: [PATCH] [REF] website_form: adapt code after jQuery update Part of task 1896658 Co-authored-by: Aaron Bohy Co-authored-by: Christophe Matthieu Co-authored-by: Mathieu Duckerts-Antoine Co-authored-by: David Monjoie Co-authored-by: Martin Geubelle Co-authored-by: svs-odoo Co-authored-by: Vincent Schippefilt --- addons/website_form/static/src/js/website_form.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/website_form/static/src/js/website_form.js b/addons/website_form/static/src/js/website_form.js index a7dcf8446b2..28e7da99046 100644 --- a/addons/website_form/static/src/js/website_form.js +++ b/addons/website_form/static/src/js/website_form.js @@ -13,11 +13,11 @@ odoo.define('website_form.animation', function (require) { selector: '.s_website_form', willStart: function () { - var def; + var prom; if (!$.fn.datetimepicker) { - def = ajax.loadJS("/web/static/lib/tempusdominus/tempusdominus.js"); + prom = ajax.loadJS("/web/static/lib/tempusdominus/tempusdominus.js"); } - return $.when(this._super.apply(this, arguments), def); + return Promise.all([this._super.apply(this, arguments), prom]); }, start: function (editable_mode) { @@ -117,7 +117,7 @@ odoo.define('website_form.animation', function (require) { // Post form and handle result ajax.post(this.$target.attr('action') + (this.$target.data('force_action')||this.$target.data('model_name')), form_values) .then(function (result_data) { - result_data = $.parseJSON(result_data); + result_data = JSON.parse(result_data); if (!result_data.id) { // Failure, the server didn't return the created record ID self.update_status('error'); @@ -139,7 +139,7 @@ odoo.define('website_form.animation', function (require) { self.$target[0].reset(); } }) - .fail(function (result_data){ + .guardedCatch(function (){ self.update_status('error'); }); }, @@ -238,7 +238,7 @@ odoo.define('website_form.animation', function (require) { this.$target.find('.o_website_form_send').on('click',function (e) {self.send(e);}).removeClass('disabled'); } var $result = this.$('#o_website_form_result'); - this.templates_loaded.done(function () { + this.templates_loaded.then(function () { $result.replaceWith(qweb.render("website_form.status_" + status)); }); },