[FIX] mail: show email_from if message has no author

closes odoo/odoo#118038

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Alexandre Kühn
2023-04-07 19:43:28 +02:00
parent 804d3786e8
commit d9bb64f1e9
2 changed files with 18 additions and 2 deletions
+2 -2
View File
@@ -46,8 +46,8 @@
</div>
<div class="w-100" t-att-class="{ 'flex-grow-1': message.composer }">
<div t-if="!props.squashed" class="o-mail-Message-header d-flex flex-wrap align-items-baseline">
<span t-if="message.author and shouldDisplayAuthorName" class="o-mail-Message-author" t-att-class="{ 'cursor-pointer o_redirect': hasAuthorClickable }" t-att-title="authorText" t-on-click="ev => this.onClickAuthor(ev)">
<strong class="me-1 text-truncate" t-esc="message.author.name"/>
<span t-if="(message.author or message.email_from) and shouldDisplayAuthorName" class="o-mail-Message-author" t-att-class="{ 'cursor-pointer o_redirect': hasAuthorClickable }" t-att-title="authorText" t-on-click="ev => this.onClickAuthor(ev)">
<strong class="me-1 text-truncate"><t t-if="message.author" t-esc="message.author.name"/><t t-else="" t-esc="message.email_from"/></strong>
</span>
<small t-if="!message.isTransient" class="o-mail-Message-date text-muted opacity-50" t-att-class="{ 'me-2': !isAlignedRight }" t-att-title="message.datetimeShort">
<t t-if="shouldDisplayAuthorName">- </t>
@@ -1453,3 +1453,19 @@ QUnit.test("Avatar of unknown author", async (assert) => {
".o-mail-Message-avatar[data-src*='mail/static/src/img/email_icon.png']"
);
});
QUnit.test("Show email_from of message without author", async (assert) => {
const pyEnv = await startServer();
pyEnv["mail.message"].create({
author_id: null,
body: "<p>Want to know features and benefits of using the new software.</p>",
email_from: "md@oilcompany.fr",
message_type: "email",
subject: "Need Details",
model: "res.partner",
res_id: pyEnv.currentPartnerId,
});
const { openFormView } = await start();
await openFormView("res.partner", pyEnv.currentPartnerId);
assert.containsOnce($, ".o-mail-Message-header:contains(md@oilcompany.fr)");
});