From aa07146421eeed37d3398dbd2114427e874fc275 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 26 Feb 2021 11:33:38 +0000 Subject: [PATCH] [IMP] web: boot.js: throw even if not in debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, when a module wasn't correctly defined (e.g. wrong format for dependencies, wrong format for module name, name already defined...), an error was thrown but only in debug mode. In non debug mode, the problem was simply ignored, which is wrong. An example of harmful consequence would be the following: if someone defines a new test file and uses an already used module name, he won't be notified of his mistake unless he runs the suite in debug mode. If he doesn't, the runbot won't detect it either as it runs tests in non debug mode. It would then lead to one of the two test suites not being executed. Fun fact: a lazy loaded file was actually loaded twice, but we were only notified in debug mode. With this change, it made the test suite fail all the time, no matter the mode. We simply removed the file from the page source, and let the first test needing it lazy load it. closes odoo/odoo#66918 Signed-off-by: Géry Debongnie (ged) --- addons/web/static/src/js/boot.js | 24 +++++++++++------------- addons/web/views/webclient_templates.xml | 1 - 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/addons/web/static/src/js/boot.js b/addons/web/static/src/js/boot.js index 85463e6c371..468eb33fbab 100644 --- a/addons/web/static/src/js/boot.js +++ b/addons/web/static/src/js/boot.js @@ -123,19 +123,17 @@ }); } - if (odoo.debug) { - if (!(deps instanceof Array)) { - throw new Error('Dependencies should be defined by an array', deps); - } - if (typeof factory !== 'function') { - throw new Error('Factory should be defined by a function', factory); - } - if (typeof name !== 'string') { - throw new Error("Invalid name definition (should be a string", name); - } - if (name in factories) { - throw new Error("Service " + name + " already defined"); - } + if (!(deps instanceof Array)) { + throw new Error('Dependencies should be defined by an array', deps); + } + if (typeof factory !== 'function') { + throw new Error('Factory should be defined by a function', factory); + } + if (typeof name !== 'string') { + throw new Error("Invalid name definition (should be a string", name); + } + if (name in factories) { + throw new Error("Service " + name + " already defined"); } factory.deps = deps; diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml index 1e2e2fc9f91..7ee7c5877d7 100644 --- a/addons/web/views/webclient_templates.xml +++ b/addons/web/views/webclient_templates.xml @@ -640,7 +640,6 @@ -