[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)
This commit is contained in:
qsm-odoo
2017-12-19 10:46:22 +01:00
parent ae57243dfb
commit 91b3a4fa8c
+12 -8
View File
@@ -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;