From 93938cfdf363e8643c3e7fee047e3dbf5dd7fa1a Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 12 Sep 2023 12:20:08 +0200 Subject: [PATCH] [IMP] web,*: remove assets_backend_prod_only This commit reworks a little bit the backend assets to remove a bundle and thus save a call at webclient startup. The bundle "assets_backend_prod_only" existed only to allow to add files in production, but not in the tests (typically, the file that spawns the webclient). This commit introduces a new bundle "web.assets_web" that contains "assets_backend" and the few files that we only want in production. In the /web page, we now load "assets_web" instead of "assets_backend" and "assets_backend_prod_only". In the /web/tests page, we keep loading "assets_backend", which is now directly included into "web.tests_assets". For the sake of consistency, this commit also renames the dark mode bundle "dark_mode_assets_backend" into "assets_web_dark". closes odoo/odoo#135204 Related: odoo/enterprise#47316 Signed-off-by: Samuel Degueldre (sad) --- addons/bus/tests/test_assetsbundle.py | 2 +- addons/hr_holidays/__manifest__.py | 2 +- addons/im_livechat/__manifest__.py | 1 - addons/mail/__manifest__.py | 2 +- addons/spreadsheet/__manifest__.py | 2 +- addons/survey/__manifest__.py | 2 +- addons/web/__manifest__.py | 17 ++++++++++------- addons/web/views/webclient_templates.xml | 9 ++------- addons/web_editor/__manifest__.py | 2 +- addons/website/__manifest__.py | 2 +- odoo/addons/base/models/assetsbundle.py | 2 +- 11 files changed, 20 insertions(+), 23 deletions(-) diff --git a/addons/bus/tests/test_assetsbundle.py b/addons/bus/tests/test_assetsbundle.py index 61a5db5b034..2c44b18da6b 100644 --- a/addons/bus/tests/test_assetsbundle.py +++ b/addons/bus/tests/test_assetsbundle.py @@ -16,7 +16,7 @@ class BusWebTests(odoo.tests.HttpCase): """ db_name = self.env.registry.db_name # start from a clean slate - self.env['ir.attachment'].search([('name', 'ilike', 'web.assets_backend%')]).unlink() + self.env['ir.attachment'].search([('name', 'ilike', 'web.assets_web%')]).unlink() self.env.registry.clear_cache() sendones = [] diff --git a/addons/hr_holidays/__manifest__.py b/addons/hr_holidays/__manifest__.py index a3030898750..53f9ffba8e7 100644 --- a/addons/hr_holidays/__manifest__.py +++ b/addons/hr_holidays/__manifest__.py @@ -67,7 +67,7 @@ A synchronization with an internal agenda (Meetings of the CRM module) is also p # Don't include dark mode files in light mode ('remove', 'hr_holidays/static/src/**/*.dark.scss'), ], - "web.dark_mode_assets_backend": [ + "web.assets_web_dark": [ 'hr_holidays/static/src/**/*.dark.scss', ], 'web.tests_assets': [ diff --git a/addons/im_livechat/__manifest__.py b/addons/im_livechat/__manifest__.py index 39ac557b485..6e38022287c 100644 --- a/addons/im_livechat/__manifest__.py +++ b/addons/im_livechat/__manifest__.py @@ -133,7 +133,6 @@ Help your customers with this chat, and analyse their feedback. 'im_livechat/static/src/embed/external/**/*', ], 'im_livechat.embed_test_assets': [ - ('include', 'web.assets_backend'), ('include', 'web.tests_assets'), ('remove', 'web/static/tests/mock_server_tests.js'), ('remove', 'im_livechat/static/**'), diff --git a/addons/mail/__manifest__.py b/addons/mail/__manifest__.py index db249488b15..1685a33d92a 100644 --- a/addons/mail/__manifest__.py +++ b/addons/mail/__manifest__.py @@ -143,7 +143,7 @@ For more specific needs, you may also assign custom-defined actions ('remove', 'mail/static/src/discuss/**/*.dark.scss'), 'mail/static/src/views/fields/**/*', ], - "web.dark_mode_assets_backend": [ + "web.assets_web_dark": [ 'mail/static/src/**/*.dark.scss', ], 'mail.assets_discuss_public_test_tours': [ diff --git a/addons/spreadsheet/__manifest__.py b/addons/spreadsheet/__manifest__.py index 472f57b8227..2af3a2c79d4 100644 --- a/addons/spreadsheet/__manifest__.py +++ b/addons/spreadsheet/__manifest__.py @@ -75,7 +75,7 @@ ('remove', 'spreadsheet/static/src/public_readonly_app/**/*.scss'), ('remove', 'spreadsheet/static/src/**/*.dark.scss'), ], - "web.dark_mode_assets_backend": [ + "web.assets_web_dark": [ 'spreadsheet/static/src/**/*.dark.scss', ], 'web.qunit_suite_tests': [ diff --git a/addons/survey/__manifest__.py b/addons/survey/__manifest__.py index 45364e3c95d..8fe4542603e 100644 --- a/addons/survey/__manifest__.py +++ b/addons/survey/__manifest__.py @@ -100,7 +100,7 @@ sent mails with personal token for the invitation of the survey. 'survey/static/src/scss/survey_templates_results.scss', 'survey/static/src/js/tours/survey_tour.js', ], - "web.dark_mode_assets_backend": [ + "web.assets_web_dark": [ 'survey/static/src/scss/*.dark.scss', ], 'web.assets_tests': [ diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 0049ea746e6..d951a36cfc9 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -152,6 +152,12 @@ This module provides the core of the Odoo Web Client. # Don't include dark mode files in light mode ('remove', 'web/static/src/**/*.dark.scss'), ], + 'web.assets_web': [ + ('include', 'web.assets_backend'), + 'web/static/src/main.js', + 'web/static/src/legacy/legacy_setup.js', + 'web/static/src/start.js', + ], 'web.assets_frontend_minimal': [ 'web/static/src/legacy/js/promise_extension.js', 'web/static/src/module_loader.js', @@ -276,11 +282,6 @@ This module provides the core of the Odoo Web Client. ('remove', 'web/static/src/legacy/js/core/cookie_utils.js'), ('remove', 'web/static/src/legacy/js/public/lazyloader.js'), ], - 'web.assets_backend_prod_only': [ - 'web/static/src/main.js', - 'web/static/src/start.js', - 'web/static/src/legacy/legacy_setup.js', - ], # Optional Bundle for PDFJS lib # Since PDFJS is quite huge (80000≈ lines), please only load it when it is necessary. # For now, it is only use to display the PDF slide Viewer during an embed. @@ -347,8 +348,8 @@ This module provides the core of the Odoo Web Client. # --------------------------------------------------------------------- # COLOR SCHEME BUNDLES # --------------------------------------------------------------------- - "web.dark_mode_assets_backend": [ - ('include', 'web.assets_backend'), + "web.assets_web_dark": [ + ('include', 'web.assets_web'), 'web/static/src/**/*.dark.scss', ], @@ -435,6 +436,8 @@ This module provides the core of the Odoo Web Client. 'web/static/tests/ignore_missing_deps_stop.js', ], 'web.tests_assets': [ + ('include', 'web.assets_backend'), + 'web/static/tests/patch_translations.js', 'web/static/lib/qunit/qunit-2.9.1.css', 'web/static/lib/qunit/qunit-2.9.1.js', diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml index fa76ed1a162..3d1db2ab2e8 100644 --- a/addons/web/views/webclient_templates.xml +++ b/addons/web/views/webclient_templates.xml @@ -217,8 +217,6 @@ Web Tests - - @@ -236,8 +234,6 @@ - - @@ -274,12 +270,11 @@ } - + - + - diff --git a/addons/web_editor/__manifest__.py b/addons/web_editor/__manifest__.py index b9feb1a0190..dd468d425fc 100644 --- a/addons/web_editor/__manifest__.py +++ b/addons/web_editor/__manifest__.py @@ -199,7 +199,7 @@ Odoo Web Editor widget. ('include', 'web_editor.assets_wysiwyg'), ], - "web.dark_mode_assets_backend": [ + "web.assets_web_dark": [ 'web_editor/static/src/scss/odoo-editor/powerbox.dark.scss', 'web_editor/static/src/scss/odoo-editor/tablepicker.dark.scss', 'web_editor/static/src/scss/odoo-editor/tableui.dark.scss', diff --git a/addons/website/__manifest__.py b/addons/website/__manifest__.py index a3b130e8205..6c911e67330 100644 --- a/addons/website/__manifest__.py +++ b/addons/website/__manifest__.py @@ -188,7 +188,7 @@ # Don't include dark mode files in light mode ('remove', 'website/static/src/client_actions/*/*.dark.scss'), ], - "web.dark_mode_assets_backend": [ + "web.assets_web_dark": [ 'website/static/src/components/dialog/*.dark.scss', 'website/static/src/scss/website.backend.dark.scss', 'website/static/src/client_actions/*/*.dark.scss', diff --git a/odoo/addons/base/models/assetsbundle.py b/odoo/addons/base/models/assetsbundle.py index 0a8c03ee18d..afbd947082e 100644 --- a/odoo/addons/base/models/assetsbundle.py +++ b/odoo/addons/base/models/assetsbundle.py @@ -55,7 +55,7 @@ class AssetsBundle(object): rx_preprocess_imports = re.compile("""(@import\s?['"]([^'"]+)['"](;?))""") rx_css_split = re.compile("\/\*\! ([a-f0-9-]+) \*\/") - TRACKED_BUNDLES = ['web.assets_backend'] + TRACKED_BUNDLES = ['web.assets_web'] def __init__(self, name, files, external_assets=(), env=None, css=True, js=True, debug_assets=False, rtl=False, assets_params=None): """