[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) <qsm@odoo.com>
Co-authored-by: Adrien Milis <miad@odoo.com>
This commit is contained in:
Serge Bayet (seba)
2024-04-25 17:06:59 +00:00
committed by qsm-odoo
co-authored by Adrien Milis
parent c2c856abd9
commit 8b4e56d84e
2 changed files with 10 additions and 3 deletions
@@ -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;
},
@@ -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",
}],
});