[FIX] mail: set name with default name instead of email
Steps to reproduce:
- Install `website_crm` module (for test purpose)
- Go to `Contact Us` page on website
- Edit the page
- Change the submit button to create an opportunity instead, then save
- Fill the form and save
- Go back to CRM app and open the opportunity just created
- In the chatter, try to send a message
- Click on the checkbox of the suggested recipient (to enable it)
Issue:
- Email is displayed twice in the suggested recipients before click
(instead of name + email or just email if same as name)
- Email is set as default name in the opened dialog
Cause:
- Displaying email even if same as name
- Not setting the fields with default values (received from
`/mail/thread/data` rpc call)
Solution:
- Don't display email if same as name
- For the suggested recipient label (next checkbox) : set name with
default name value if name parsed from mail is same value as email
- For the default values in the opened dialog: set default values with
defaults received from `/mail/thread/data` rpc call
opw-3470295
closes odoo/odoo#135951
X-original-commit: 02ef0425a1f4ae30d846f6c57489cdebc3b4bbad
Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<input t-attf-id="{{ props.recipient.id }}_checkbox" class="form-check-input" type="checkbox" t-att-checked="props.recipient.checked" t-on-change="onChangeCheckbox"/>
|
||||
<label class="form-check-label" t-attf-for="{{ props.recipient.id }}_checkbox">
|
||||
<t t-if="props.recipient.name" t-esc="props.recipient.name"/>
|
||||
<t t-if="props.recipient.email">
|
||||
<t t-if="props.recipient.email and props.recipient.email !== props.recipient.name">
|
||||
(<t t-esc="props.recipient.email"/>)
|
||||
</t>
|
||||
</label>
|
||||
|
||||
@@ -147,8 +147,11 @@ patch(ThreadService.prototype, {
|
||||
async insertSuggestedRecipients(thread, dataList) {
|
||||
const recipients = [];
|
||||
for (const data of dataList) {
|
||||
const [partner_id, emailInfo, lang, reason] = data;
|
||||
const [name, email] = emailInfo && parseEmail(emailInfo);
|
||||
const [partner_id, emailInfo, lang, reason, customerInfo] = data;
|
||||
let [name, email] = emailInfo ? parseEmail(emailInfo) : [];
|
||||
if ((!name || name === email) && customerInfo?.name) {
|
||||
name = customerInfo.name;
|
||||
}
|
||||
recipients.push({
|
||||
id: nextId++,
|
||||
name,
|
||||
|
||||
@@ -71,7 +71,7 @@ QUnit.test(
|
||||
});
|
||||
await click("button", { text: "Send message" });
|
||||
await contains(".o-mail-SuggestedRecipient", {
|
||||
text: "john@test.be (john@test.be)",
|
||||
text: "john@test.be",
|
||||
contains: ["input[type=checkbox]:checked"],
|
||||
});
|
||||
await contains(".o-mail-SuggestedRecipient", {
|
||||
@@ -111,7 +111,7 @@ QUnit.test(
|
||||
});
|
||||
await click("button", { text: "Send message" });
|
||||
await contains(".o-mail-SuggestedRecipient", {
|
||||
text: "john@test.be (john@test.be)",
|
||||
text: "john@test.be",
|
||||
contains: ["input[type=checkbox]:checked"],
|
||||
});
|
||||
await contains(".o-mail-SuggestedRecipient", {
|
||||
|
||||
Reference in New Issue
Block a user