From 8b4e56d84e1eb4f2273025f0d8d80d66b64ebb73 Mon Sep 17 00:00:00 2001 From: "Serge Bayet (seba)" Date: Tue, 23 Apr 2024 06:43:42 +0000 Subject: [PATCH] [FIX] website, *: remove number of subscribers on website form *: website_mass_mailing Before this commit, when a "Form" snippet was added and the action was changed to "Subscribe to Newsletter", the mailing lists appeared as checkbox fields with the number of subscribers in parentheses. This commit removes the display of this unnecessary information. Steps to reproduce: - Install the "Email Marketing" module and Website. - Navigate to the Website in edit mode. - Drag & drop the "Form" block (dynamic content section). - Change the form action by setting the "Action" option to "Subscribe to Newsletter". Bug: The number of subscribers appears next to the mailing list names. task-3472820 closes odoo/odoo#163336 X-original-commit: a060a1981074a83b77b28f70b49127ecb6f4f550 Signed-off-by: Quentin Smetz (qsm) Co-authored-by: Adrien Milis --- .../website/static/src/snippets/s_website_form/options.js | 6 +++++- .../static/src/js/mass_mailing_form_editor.js | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/website/static/src/snippets/s_website_form/options.js b/addons/website/static/src/snippets/s_website_form/options.js index 35278f4811e..fc3fbdbe8df 100644 --- a/addons/website/static/src/snippets/s_website_form/options.js +++ b/addons/website/static/src/snippets/s_website_form/options.js @@ -71,7 +71,11 @@ const FormEditor = options.Class.extend({ display_name: el[1], })); } else if (field.relation && field.relation !== 'ir.attachment') { - field.records = await this.orm.searchRead(field.relation, field.domain || [], ["display_name"]); + const fieldNames = field.fieldName ? [field.fieldName] : ["display_name"]; + field.records = await this.orm.searchRead(field.relation, field.domain || [], fieldNames); + if (field.fieldName) { + field.records.forEach(r => r["display_name"] = r[field.fieldName]); + } } return field.records; }, diff --git a/addons/website_mass_mailing/static/src/js/mass_mailing_form_editor.js b/addons/website_mass_mailing/static/src/js/mass_mailing_form_editor.js index 07ab2fe4128..1318e04e42d 100644 --- a/addons/website_mass_mailing/static/src/js/mass_mailing_form_editor.js +++ b/addons/website_mass_mailing/static/src/js/mass_mailing_form_editor.js @@ -7,18 +7,21 @@ FormEditorRegistry.add('create_mailing_contact', { formFields: [{ name: 'name', required: true, + fillWith: "name", string: _t('Your Name'), type: 'char', }, { name: 'email', - required: true, + modelRequired: true, + fillWith: "email", string: _t('Your Email'), type: 'email', }, { name: 'list_ids', relation: 'mailing.list', - required: true, + modelRequired: true, string: _t('Subscribe to'), type: 'many2many', + fieldName: "name", }], });