From 3a77deb6c4ef3b04373d61d97eff325a3e518504 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Wed, 20 Jun 2018 17:25:41 +0200 Subject: [PATCH] [FIX] account, portal: use new syntax in sidebar widget There is a new syntax for widgets, among other things it allows the widget code to be partly executed before the DOM is ready, speeding the process. Courtesy of QSM opw-39876 --- .../static/src/js/account_portal_sidebar.js | 26 +++++++++++++------ addons/portal/static/src/js/portal_sidebar.js | 1 - 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/addons/account/static/src/js/account_portal_sidebar.js b/addons/account/static/src/js/account_portal_sidebar.js index 3b0ab0e6afe..5323c09e0f3 100644 --- a/addons/account/static/src/js/account_portal_sidebar.js +++ b/addons/account/static/src/js/account_portal_sidebar.js @@ -1,7 +1,24 @@ -odoo.define('account.AccountPortalSidebar', function (require) { +odoo.define('account.AccountPortalSidebar.instance', function (require) { "use strict"; require('web.dom_ready'); +var AccountPortalSidebar = require('account.AccountPortalSidebar'); + +if (!$('.o_portal_invoice_sidebar').length) { + return $.Deferred().reject("DOM doesn't contain '.o_portal_invoice_sidebar'"); +} + +var account_portal_sidebar = new AccountPortalSidebar(); +return account_portal_sidebar.attachTo($('.o_portal_invoice_sidebar')).then(function () { + return account_portal_sidebar; +}); +}); + +//============================================================================== + +odoo.define('account.AccountPortalSidebar', function (require) { +"use strict"; + var PortalSidebar = require('portal.PortalSidebar'); var AccountPortalSidebar = PortalSidebar.extend({ @@ -46,13 +63,6 @@ var AccountPortalSidebar = PortalSidebar.extend({ }, }); -$(function () { - if (!$('.o_portal_invoice_sidebar').length) { - return $.Deferred().reject("DOM doesn't contain '.o_portal_invoice_sidebar'"); - } - var account_portal_sidebar = new AccountPortalSidebar(); - account_portal_sidebar.attachTo($('.o_portal_invoice_sidebar')); -}); return AccountPortalSidebar; }); diff --git a/addons/portal/static/src/js/portal_sidebar.js b/addons/portal/static/src/js/portal_sidebar.js index df5c8940c76..937655d1d97 100644 --- a/addons/portal/static/src/js/portal_sidebar.js +++ b/addons/portal/static/src/js/portal_sidebar.js @@ -1,7 +1,6 @@ odoo.define('portal.PortalSidebar', function (require) { "use strict"; -require('web.dom_ready'); var config = require('web.config'); var core = require('web.core'); var Widget = require('web.Widget');