From 82b31aa9ffb21f08a406caede5cbb7342ea0ae76 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 3 Jun 2019 14:18:48 +0000 Subject: [PATCH] [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 --- .../account/static/src/js/account_portal_sidebar.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/account/static/src/js/account_portal_sidebar.js b/addons/account/static/src/js/account_portal_sidebar.js index 92a31e69fe5..ded90bb968e 100644 --- a/addons/account/static/src/js/account_portal_sidebar.js +++ b/addons/account/static/src/js/account_portal_sidebar.js @@ -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; },