From 0c0f405018fa85fec0c2f5d54b5d0659040bb39f Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 30 Mar 2023 16:03:59 +0000 Subject: [PATCH] [FIX] website_mass_mailing: add missing s_newsletter_list class Commit [1], combined with commit [2], added a s_newsletter_list class on two newsletter snippets to move the related newsletter option to the root node that contains the newsletter subscription input. The problem is that no migration script was made thus making it impossible to customize old snippets anymore. We could mark them as outdated... but it happens that marking a snippet as outdated (by incrementing the vxml counter for example) is not straightforward (users that already migrated would not get that XML update). This creates a widget that tries to fix snippets that were malformed, on page load. An upgrade script should be made to fix databases and get rid of this in the future. opw-3243399 opw-3244080 opw-3246089 opw-3246194 opw-3246435 opw-3248473 closes odoo/odoo#117416 X-original-commit: 8d7eaaf916250086cd2f628bd2f3b07cc825959a Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/website_mass_mailing.js | 21 +++++++++++++++++++ .../views/snippets_templates.xml | 8 +++++++ 2 files changed, 29 insertions(+) diff --git a/addons/website_mass_mailing/static/src/js/website_mass_mailing.js b/addons/website_mass_mailing/static/src/js/website_mass_mailing.js index c13aa9dcda2..f09476e1a5a 100644 --- a/addons/website_mass_mailing/static/src/js/website_mass_mailing.js +++ b/addons/website_mass_mailing/static/src/js/website_mass_mailing.js @@ -140,4 +140,25 @@ publicWidget.registry.subscribe = publicWidget.Widget.extend({ }); }, }); + +/** + * This widget tries to fix snippets that were malformed because of a missing + * upgrade script. Without this, some newsletter snippets coming from users + * upgraded from a version lower than 16.0 may not be able to update their + * newsletter block. + * + * TODO an upgrade script should be made to fix databases and get rid of this. + */ +publicWidget.registry.fixNewsletterListClass = publicWidget.Widget.extend({ + selector: '.s_newsletter_subscribe_form:not(.s_subscription_list), .s_newsletter_block', + + /** + * @override + */ + start() { + this.$target[0].classList.add('s_newsletter_list'); + return this._super(...arguments); + }, +}); + }); diff --git a/addons/website_mass_mailing/views/snippets_templates.xml b/addons/website_mass_mailing/views/snippets_templates.xml index 14552219114..4949f08708f 100644 --- a/addons/website_mass_mailing/views/snippets_templates.xml +++ b/addons/website_mass_mailing/views/snippets_templates.xml @@ -23,6 +23,10 @@ + +