From 91b3a4fa8c44cbb9b0a2a0142363e136f99fd04c Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 18 Dec 2017 16:41:47 +0100 Subject: [PATCH] [FIX] payment: properly allow `PaymentForm` extensions Commit https://github.com/odoo/odoo/commit/be650c5979d6d427ad79bc23f0edc1d10290f881#diff-b448c1be5e302f4819079161e4fe3de9L369 added a `require` in the middle of a file, making the whole file require the DOM to be ready. This was not really a problem as the module did not return anything... until https://github.com/odoo/odoo/commit/d2815c474d7ab24a06f5365d967a602119252b95 Proper way to fix this would be to split the module in two parts, one requiring the DOM to be ready and not the other one. However, this commit chose to do a fix as stable as possible. See https://github.com/odoo/odoo/issues/21702 (and https://github.com/odoo/odoo/issues/21321) --- addons/payment/static/src/js/payment_form.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js index 7c0a51d408f..049b7a55328 100644 --- a/addons/payment/static/src/js/payment_form.js +++ b/addons/payment/static/src/js/payment_form.js @@ -409,14 +409,18 @@ odoo.define('payment.payment_form', function (require) { }, }); - 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'"); - } - $('.o_payment_form').each(function () { - var $elem = $(this); - var form = new PaymentForm(null, $elem.data()); - form.attachTo($elem); + $(function () { + // TODO move this to another module, requiring dom_ready and rejecting + // the returned deferred to get the proper message + if (!$('.o_payment_form').length) { + console.log("DOM doesn't contain '.o_payment_form'"); + return; + } + $('.o_payment_form').each(function () { + var $elem = $(this); + var form = new PaymentForm(null, $elem.data()); + form.attachTo($elem); + }); }); return PaymentForm;