[FIX] account: fix setting invoice iframe height on load

Since the JS is lazy loaded, the iframes in the page are already loaded
once the javascript is executed. So, waiting for the "load" event at
that moment is useless as it will never happen as it already did.

Part of https://github.com/odoo/odoo/pull/32181
task-1961045
This commit is contained in:
qsm-odoo
2019-06-04 07:57:20 +00:00
parent dd19bcef84
commit 82b31aa9ff
@@ -15,10 +15,19 @@ publicWidget.registry.AccountPortalSidebar = PortalSidebar.extend({
*/
start: function () {
var def = this._super.apply(this, arguments);
var $invoiceHtml = this.$el.find('iframe#invoice_html');
var updateIframeSize = this._updateIframeSize.bind(this, $invoiceHtml);
$invoiceHtml.on('load', updateIframeSize);
$(window).on('resize', updateIframeSize);
var iframeDoc = $invoiceHtml[0].contentDocument || $invoiceHtml[0].contentWindow.document;
if (iframeDoc.readyState === 'complete') {
updateIframeSize();
} else {
$invoiceHtml.on('load', updateIframeSize);
}
return def;
},