[FIX] mail: do not display false if missing email

'false' is displayed in the popover next to the recipients in the absence of an email address as well as the title of the recipients

If the partner has no email, it should show something like "[name] (no email address)]"

test added

task-3787703

closes odoo/odoo#157850

X-original-commit: 40a2df25301daaf24c123e0b67bff408eb8cd897
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Zelong Lin (zel) <zel@odoo.com>
This commit is contained in:
zel-odoo
2024-03-15 18:42:46 +00:00
parent 342cf4159a
commit a6746497d7
5 changed files with 48 additions and 4 deletions
+7
View File
@@ -10320,6 +10320,13 @@ msgstr ""
msgid "Your name"
msgstr ""
#. module: mail
#. odoo-javascript
#: code:addons/mail/static/src/core/web/recipient_list.js:0
#, python-format
msgid "[%(name)s] (no email address)"
msgstr ""
#. module: mail
#. odoo-python
#: code:addons/mail/models/mail_alias.py:0
+3 -3
View File
@@ -236,9 +236,9 @@ export class Chatter extends Component {
.slice(0, 5)
.map(({ partner }) => {
const text = partner.email ? partner.emailWithoutDomain : partner.name;
return `<span class="text-muted" title="${escape(partner.email)}">${escape(
text
)}</span>`;
return `<span class="text-muted" title="${escape(
partner.email || _t("no email address")
)}">${escape(text)}</span>`;
});
const formatter = new Intl.ListFormat(
this.store.env.services["user"].lang?.replace("_", "-"),
@@ -3,6 +3,8 @@
import { useVisible } from "@mail/utils/common/hooks";
import { Component, useState } from "@odoo/owl";
import { useService } from "@web/core/utils/hooks";
import { _t } from "@web/core/l10n/translation";
import { sprintf } from "@web/core/utils/strings";
/**
* @typedef {Object} Props
@@ -22,4 +24,11 @@ export class RecipientList extends Component {
}
});
}
getRecipientText(recipient) {
return (
recipient.partner.email ||
sprintf(_t("[%(name)s] (no email address)"), { name: recipient.partner.name })
);
}
}
@@ -5,7 +5,7 @@
<div class="o-mail-RecipientList p-2 overflow-auto">
<ul class="list-unstyled mb-0">
<li t-foreach="props.thread.recipients" t-as="recipient" t-key="recipient.id">
<t t-out="recipient.partner.email"/>
<t t-out="getRecipientText(recipient)"/>
</li>
<span t-if="!props.thread.recipientsFullyLoaded" class="btn btn-link w-100" t-on-click="() => threadService.loadMoreRecipients(props.thread)" t-ref="load-more">Load more</span>
</ul>
@@ -279,6 +279,34 @@ QUnit.test("Load 100 recipients at once", async () => {
await contains(".o-mail-RecipientList span", { count: 0, text: "Load more" });
});
QUnit.test("Load recipient without email", async () => {
const pyEnv = await startServer();
const [partnerId_1, partnerId_2] = pyEnv["res.partner"].create([
{ name: "Luigi" },
{ name: "Mario" },
]);
pyEnv["mail.followers"].create([
{
is_active: true,
partner_id: pyEnv.currentPartnerId,
res_id: partnerId_1,
res_model: "res.partner",
},
{
is_active: true,
partner_id: partnerId_2,
res_id: partnerId_1,
res_model: "res.partner",
},
]);
const { openFormView } = await start();
await openFormView("res.partner", partnerId_1);
await click("button", { text: "Send message" });
await contains("span[title='no email address']", { text: "Mario" });
await click("button[title='Show all recipients']");
await contains(".o-mail-RecipientList li", { text: "[Mario] (no email address)" });
});
QUnit.test(
'Show "Add follower" and subtypes edition/removal buttons on all followers if user has write access',
async () => {