diff options
| author | qsm-odoo <qsm@odoo.com> | 2019-06-03 14:18:48 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2019-06-04 07:57:20 +0000 |
| commit | 82b31aa9ffb21f08a406caede5cbb7342ea0ae76 (patch) | |
| tree | b6b5e2493bee632db9eb94e832aea5a24f1ad511 | |
| parent | dd19bcef84464de4d6fadc9033c240b01fd0100f (diff) | |
[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
| -rw-r--r-- | addons/account/static/src/js/account_portal_sidebar.js | 11 |
1 files changed, 10 insertions, 1 deletions
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; }, |
