From 4703e4a2efa9213979307e4d3dedeedc61ad0fc3 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Wed, 2 Aug 2023 08:28:16 +0000 Subject: [PATCH 01/15] [REF] web: Add all templates in Owl app Before this commit, only templates with owl=1 were added to the owl app. Now, all templates are added to the owl app, and none of the templates is added to qweb. Part of task~3443861 Part-of: odoo/odoo#130467 --- addons/web/__manifest__.py | 2 -- addons/web/static/src/core/assets.js | 14 ++++++++++---- addons/web/static/src/legacy/js/assets.js | 20 -------------------- addons/website_slides/__manifest__.py | 1 - 4 files changed, 10 insertions(+), 27 deletions(-) delete mode 100644 addons/web/static/src/legacy/js/assets.js diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 2c633f76f3d..38643f7bf7b 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -111,7 +111,6 @@ This module provides the core of the Odoo Web Client. 'web/static/lib/clipboard/clipboard.js', 'web/static/lib/jSignature/jSignatureCustom.js', 'web/static/lib/qweb/qweb2.js', - 'web/static/src/legacy/js/assets.js', 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', 'web/static/src/legacy/js/libs/content-disposition.js', @@ -309,7 +308,6 @@ This module provides the core of the Odoo Web Client. 'web/static/lib/clipboard/clipboard.js', 'web/static/lib/jSignature/jSignatureCustom.js', 'web/static/lib/qweb/qweb2.js', - 'web/static/src/legacy/js/assets.js', 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', 'web/static/src/legacy/js/libs/content-disposition.js', diff --git a/addons/web/static/src/core/assets.js b/addons/web/static/src/core/assets.js index e149acdd51c..27aff25c951 100644 --- a/addons/web/static/src/core/assets.js +++ b/addons/web/static/src/core/assets.js @@ -69,9 +69,16 @@ export const _loadCSS = (assets.loadCSS = memoize(function loadCSS(url, retryCou linkEl.addEventListener("load", () => resolve(true)); linkEl.addEventListener("error", async () => { if (retryCount < assets.retries.count) { - await new Promise(resolve => setTimeout(resolve, assets.retries.delay + assets.retries.extraDelay * retryCount)); + await new Promise((resolve) => + setTimeout( + resolve, + assets.retries.delay + assets.retries.extraDelay * retryCount + ) + ); linkEl.remove(); - loadCSS(url, retryCount + 1).then(resolve).catch(reject); + loadCSS(url, retryCount + 1) + .then(resolve) + .catch(reject); } else { reject(new AssetsLoadingError(`The loading of ${url} failed`)); } @@ -105,8 +112,7 @@ export const _loadXML = (assets.loadXML = function loadXML(xml, app = defaultApp throw new Error(doc.querySelector("parsererror").textContent.trim()); } - for (const element of doc.querySelectorAll("templates > [t-name][owl]")) { - element.removeAttribute("owl"); + for (const element of doc.querySelectorAll("templates > [t-name]")) { const name = element.getAttribute("t-name"); const previous = templates.querySelector(`[t-name="${name}"]`); if (previous) { diff --git a/addons/web/static/src/legacy/js/assets.js b/addons/web/static/src/legacy/js/assets.js deleted file mode 100644 index 8edc49e1942..00000000000 --- a/addons/web/static/src/legacy/js/assets.js +++ /dev/null @@ -1,20 +0,0 @@ -/** @odoo-module **/ - -import {assets} from "@web/core/assets"; - -const loadXML = assets.loadXML; -assets.loadXML = function (xml, app) { - loadXML(xml, app); - - const doc = new DOMParser().parseFromString(xml, "text/xml"); - const qwebTemplates = document.createElement("templates"); - for (const element of doc.querySelectorAll("templates > [t-name]:not([owl]), templates > [t-extend]:not([owl])")) { - qwebTemplates.appendChild(element); - } - - // don't use require to apply the patch before the first template loading. - odoo.ready('@web/legacy/js/services/core').then(function () { - const { qweb } = odoo.__DEBUG__.services['@web/legacy/js/services/core']; - qweb.add_template(qwebTemplates); - }); -} diff --git a/addons/website_slides/__manifest__.py b/addons/website_slides/__manifest__.py index 7ea5fc07717..68f40322122 100644 --- a/addons/website_slides/__manifest__.py +++ b/addons/website_slides/__manifest__.py @@ -192,7 +192,6 @@ Featuring 'web/static/lib/clipboard/clipboard.js', 'web/static/lib/jSignature/jSignatureCustom.js', 'web/static/lib/qweb/qweb2.js', - 'web/static/src/legacy/js/assets.js', 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', 'web/static/src/legacy/js/libs/content-disposition.js', From 7b1d82aa9b30e0408bd7f537a0e334fe6c26d02f Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Wed, 2 Aug 2023 08:58:58 +0000 Subject: [PATCH 02/15] [REF] *: add t-key when needed on the template As all the templates are now imported in the owl app, the templates must comply to owl. t-key is mandatory when using a t-foreach Part of task~3443861 Part-of: odoo/odoo#130467 --- .../xml/legacy_account_journal_activity.xml | 2 +- .../static/src/xml/legacy_account_payment.xml | 2 +- .../src/xml/legacy_account_type_selection.xml | 4 +- .../static/src/xml/expense_dashboard.xml | 2 +- addons/mail_group/views/portal_templates.xml | 2 +- .../static/src/xml/mass_mailing.xml | 6 +-- .../src/xml/payment_post_processing.xml | 12 ++--- .../portal/static/src/xml/portal_chatter.xml | 6 +-- .../static/src/xml/portal_tools.xml | 10 ++-- .../portal_rating/views/rating_templates.xml | 4 +- .../src/xml/survey_breadcrumb_templates.xml | 2 +- .../js/editor/odoo-editor/src/qweb_sample.js | 6 +-- .../static/src/xml/wysiwyg_colorpicker.xml | 54 ++++++++++--------- .../src/snippets/s_dynamic_snippet/000.xml | 4 +- .../s_dynamic_snippet_carousel/000.xml | 6 +-- .../src/snippets/s_image_gallery/000.xml | 4 +- .../static/src/snippets/s_searchbar/000.xml | 2 +- .../website/static/src/xml/website.share.xml | 2 +- .../static/src/xml/website_form_editor.xml | 8 +-- addons/website/views/website_templates.xml | 2 +- .../event_booth_registration_templates.xml | 2 +- .../src/xml/website_event_meeting_room.xml | 2 +- .../static/src/xml/quiz_templates.xml | 4 +- .../static/src/xml/public_templates.xml | 6 +-- .../src/snippets/s_donation/options.xml | 4 +- .../static/src/xml/autocomplete.xml | 2 +- .../static/src/xml/slide_quiz.xml | 6 +-- .../static/src/xml/slide_quiz_create.xml | 4 +- .../static/src/xml/website_slides_upload.xml | 4 +- 29 files changed, 89 insertions(+), 85 deletions(-) diff --git a/addons/account/static/src/xml/legacy_account_journal_activity.xml b/addons/account/static/src/xml/legacy_account_journal_activity.xml index d0b71dc1276..27cadef5cf2 100644 --- a/addons/account/static/src/xml/legacy_account_journal_activity.xml +++ b/addons/account/static/src/xml/legacy_account_journal_activity.xml @@ -3,7 +3,7 @@ - +
- +
diff --git a/addons/account/static/src/xml/legacy_account_type_selection.xml b/addons/account/static/src/xml/legacy_account_type_selection.xml index dbc6904eb9b..e751b83e944 100644 --- a/addons/account/static/src/xml/legacy_account_type_selection.xml +++ b/addons/account/static/src/xml/legacy_account_type_selection.xml @@ -3,10 +3,10 @@ - + - + diff --git a/addons/hr_expense/static/src/xml/expense_dashboard.xml b/addons/hr_expense/static/src/xml/expense_dashboard.xml index 63058ec3fdf..ba9b1dce78e 100644 --- a/addons/hr_expense/static/src/xml/expense_dashboard.xml +++ b/addons/hr_expense/static/src/xml/expense_dashboard.xml @@ -3,7 +3,7 @@
- +
diff --git a/addons/mail_group/views/portal_templates.xml b/addons/mail_group/views/portal_templates.xml index 49f6d0783a2..c0938cbe67a 100644 --- a/addons/mail_group/views/portal_templates.xml +++ b/addons/mail_group/views/portal_templates.xml @@ -215,7 +215,7 @@

diff --git a/addons/account/static/src/components/account_type_selection/account_type_selection.xml b/addons/account/static/src/components/account_type_selection/account_type_selection.xml index 0b301bfd389..5e0f60f7fa2 100644 --- a/addons/account/static/src/components/account_type_selection/account_type_selection.xml +++ b/addons/account/static/src/components/account_type_selection/account_type_selection.xml @@ -2,7 +2,7 @@ - + diff --git a/addons/account/static/src/components/bills_upload/bills_upload.xml b/addons/account/static/src/components/bills_upload/bills_upload.xml index e01e7159fc7..bf2ed8842ec 100644 --- a/addons/account/static/src/components/bills_upload/bills_upload.xml +++ b/addons/account/static/src/components/bills_upload/bills_upload.xml @@ -1,7 +1,7 @@ - +
- +
- + - + - + - + - + @@ -73,7 +73,7 @@ - +
- + diff --git a/addons/account/static/src/components/grouped_view_widget/grouped_view_widget.xml b/addons/account/static/src/components/grouped_view_widget/grouped_view_widget.xml index 4fbbdd24a6c..12ce877604e 100644 --- a/addons/account/static/src/components/grouped_view_widget/grouped_view_widget.xml +++ b/addons/account/static/src/components/grouped_view_widget/grouped_view_widget.xml @@ -1,6 +1,6 @@ - + @@ -16,7 +16,7 @@ - + - +
@@ -27,7 +27,7 @@
diff --git a/addons/account/static/src/components/journal_dashboard_activity/journal_dashboard_activity.xml b/addons/account/static/src/components/journal_dashboard_activity/journal_dashboard_activity.xml index 2b448ece29b..1dc87594d9b 100644 --- a/addons/account/static/src/components/journal_dashboard_activity/journal_dashboard_activity.xml +++ b/addons/account/static/src/components/journal_dashboard_activity/journal_dashboard_activity.xml @@ -2,7 +2,7 @@ - +
diff --git a/addons/account/static/src/components/mail_attachments/mail_attachments.xml b/addons/account/static/src/components/mail_attachments/mail_attachments.xml index 7d5578dd6ae..df4b53ca4f0 100644 --- a/addons/account/static/src/components/mail_attachments/mail_attachments.xml +++ b/addons/account/static/src/components/mail_attachments/mail_attachments.xml @@ -4,7 +4,7 @@ + >