summaryrefslogtreecommitdiff
path: root/addons/payment/static
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2017-12-18 16:41:47 +0100
committerqsm-odoo <qsm@odoo.com>2017-12-19 10:46:22 +0100
commit91b3a4fa8c44cbb9b0a2a0142363e136f99fd04c (patch)
tree9645633dd867c74c7b7993517fba6bcad51640b0 /addons/payment/static
parentae57243dfbe426b0ebc3e0e3db59efe4bd506954 (diff)
[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)
Diffstat (limited to 'addons/payment/static')
-rw-r--r--addons/payment/static/src/js/payment_form.js20
1 files 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;