summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components/message
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-08-27 15:07:50 +0000
committerAlexandre Kühn <aku@odoo.com>2020-08-27 16:51:50 +0000
commitc690f63de88b74bf6576fa83adcba3d57bcb1a74 (patch)
tree7c9e23cb73bd96c14e73b98992b65f155bae8e1e /addons/mail/static/src/components/message
parentae9a6aa200b5a66d5da1dc166f99261bc5ad06d0 (diff)
[FIX] mail: prevent "record created" from being twice in the chatter
task-2280184 closes odoo/odoo#56691 X-original-commit: 1af2cc1b2190623739085de83870fb415cbdccf1 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/message')
-rw-r--r--addons/mail/static/src/components/message/message.xml2
-rw-r--r--addons/mail/static/src/components/message/message_tests.js47
2 files changed, 47 insertions, 2 deletions
diff --git a/addons/mail/static/src/components/message/message.xml b/addons/mail/static/src/components/message/message.xml
index 02a0c49e20c..d248c422550 100644
--- a/addons/mail/static/src/components/message/message.xml
+++ b/addons/mail/static/src/components/message/message.xml
@@ -156,7 +156,7 @@
</t>
<div class="o_Message_content" t-ref="content">
<t t-raw="message.prettyBody"/>
- <t t-if="message.subtype_description">
+ <t t-if="message.subtype_description and !message.isBodyEqualSubtypeDescription">
<p t-esc="message.subtype_description"/>
</t>
<t t-if="trackingValues.length > 0">
diff --git a/addons/mail/static/src/components/message/message_tests.js b/addons/mail/static/src/components/message/message_tests.js
index 8e2669a8698..7f10771ce0d 100644
--- a/addons/mail/static/src/components/message/message_tests.js
+++ b/addons/mail/static/src/components/message/message_tests.js
@@ -108,7 +108,8 @@ QUnit.test('basic rendering', async function (assert) {
1,
"message should display the content"
);
- assert.strictEqual(messageEl.querySelector(`:scope .o_Message_content`).innerHTML,
+ assert.strictEqual(
+ messageEl.querySelector(`:scope .o_Message_content`).innerHTML,
"<p>Test</p>",
"message should display the correct content"
);
@@ -738,6 +739,50 @@ QUnit.test('prevent attachment delete on non-authored message', async function (
);
});
+QUnit.test('subtype description should be displayed if it is different than body', async function (assert) {
+ assert.expect(2);
+
+ await this.start();
+ const message = this.env.models['mail.message'].create({
+ body: "<p>Hello</p>",
+ id: 100,
+ subtype_description: 'Bonjour',
+ });
+ await this.createMessageComponent(message);
+ assert.containsOnce(
+ document.body,
+ '.o_Message_content',
+ "message should have content"
+ );
+ assert.strictEqual(
+ document.querySelector(`.o_Message_content`).textContent,
+ "HelloBonjour",
+ "message content should display both body and subtype description when they are different"
+ );
+});
+
+QUnit.test('subtype description should not be displayed if it is similar to body', async function (assert) {
+ assert.expect(2);
+
+ await this.start();
+ const message = this.env.models['mail.message'].create({
+ body: "<p>Hello</p>",
+ id: 100,
+ subtype_description: 'hello',
+ });
+ await this.createMessageComponent(message);
+ assert.containsOnce(
+ document.body,
+ '.o_Message_content',
+ "message should have content"
+ );
+ assert.strictEqual(
+ document.querySelector(`.o_Message_content`).textContent,
+ "Hello",
+ "message content should display only body when subtype description is similar"
+ );
+});
+
});
});
});