diff --git a/addons/mail/static/src/components/attachment_image/tests/attachment_image_tests.js b/addons/mail/static/src/components/attachment_image/tests/attachment_image_tests.js index 91e7069e1c5..4ab6df77d8f 100644 --- a/addons/mail/static/src/components/attachment_image/tests/attachment_image_tests.js +++ b/addons/mail/static/src/components/attachment_image/tests/attachment_image_tests.js @@ -39,7 +39,7 @@ QUnit.test('auto layout with image', async function (assert) { mimetype: 'image/png', name: "test.png", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "
Test
", diff --git a/addons/mail/static/src/components/attachment_list/tests/attachment_list_tests.js b/addons/mail/static/src/components/attachment_list/tests/attachment_list_tests.js index b8435891877..5ead602ddc2 100644 --- a/addons/mail/static/src/components/attachment_list/tests/attachment_list_tests.js +++ b/addons/mail/static/src/components/attachment_list/tests/attachment_list_tests.js @@ -41,7 +41,7 @@ QUnit.test('simplest layout', async function (assert) { mimetype: 'text/plain', name: "test.txt", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", @@ -113,7 +113,7 @@ QUnit.test('simplest layout + editable', async function (assert) { mimetype: 'text/plain', name: "test.txt", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", @@ -169,7 +169,7 @@ QUnit.test('layout with card details and filename and extension', async function mimetype: 'text/plain', name: "test.txt", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", @@ -201,7 +201,7 @@ QUnit.test('view attachment', async function (assert) { mimetype: 'image/png', name: "test.png", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", @@ -237,7 +237,7 @@ QUnit.test('close attachment viewer', async function (assert) { mimetype: 'image/png', name: "test.png", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", @@ -286,7 +286,7 @@ QUnit.test('clicking on the delete attachment button multiple times should do th mimetype: 'text/plain', name: "test.txt", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", @@ -328,7 +328,7 @@ QUnit.test('[technical] does not crash when the viewer is closed before image lo mimetype: 'image/png', name: "test.png", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", @@ -362,7 +362,7 @@ QUnit.test('plain text file is viewable', async function (assert) { mimetype: 'text/plain', name: "test.txt", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", @@ -387,7 +387,7 @@ QUnit.test('HTML file is viewable', async function (assert) { mimetype: 'text/html', name: "test.html", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", @@ -411,7 +411,7 @@ QUnit.test('ODT file is not viewable', async function (assert) { mimetype: 'application/vnd.oasis.opendocument.text', name: "test.odt", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", @@ -435,7 +435,7 @@ QUnit.test('DOCX file is not viewable', async function (assert) { mimetype: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', name: "test.docx", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: link(attachment), author: link(this.messaging.currentPartner), body: "Test
", diff --git a/addons/mail/static/src/components/discuss/tests/discuss_tests.js b/addons/mail/static/src/components/discuss/tests/discuss_tests.js index c4451b1f0dc..7bfa2c4b353 100644 --- a/addons/mail/static/src/components/discuss/tests/discuss_tests.js +++ b/addons/mail/static/src/components/discuss/tests/discuss_tests.js @@ -1143,7 +1143,7 @@ QUnit.test('load single message from channel initially', async function (assert) document.querySelectorAll(` .o_Discuss_thread .o_MessageList_message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 100 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 100 }).localId }"] `).length, 1, @@ -1201,7 +1201,7 @@ QUnit.test('basic rendering of message', async function (assert) { .o_Discuss_thread .o_ThreadView_messageList .o_MessageList_message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 100 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 100 }).localId }"] `); assert.strictEqual( @@ -1333,14 +1333,14 @@ QUnit.test('basic rendering of squashed message', async function (assert) { .o_Discuss_thread .o_ThreadView_messageList .o_MessageList_message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 100 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 100 }).localId }"] `); const message2 = document.querySelector(` .o_Discuss_thread .o_ThreadView_messageList .o_MessageList_message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 101 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 101 }).localId }"] `); assert.notOk( @@ -1466,14 +1466,14 @@ QUnit.test('inbox messages are never squashed', async function (assert) { .o_Discuss_thread .o_ThreadView_messageList .o_MessageList_message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 100 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 100 }).localId }"] `); const message2 = document.querySelector(` .o_Discuss_thread .o_ThreadView_messageList .o_MessageList_message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 101 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 101 }).localId }"] `); assert.notOk( @@ -2110,7 +2110,7 @@ QUnit.test('redirect to author (open chat)', async function (assert) { const msg1 = document.querySelector(` .o_Discuss_thread .o_Message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 100 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 100 }).localId }"] `); assert.strictEqual( @@ -2799,7 +2799,7 @@ QUnit.test('post a simple message', async function (assert) { const message = document.querySelector(`.o_Message`); assert.strictEqual( message.dataset.messageLocalId, - this.messaging.models['mail.message'].findFromIdentifyingData({ id: postedMessageId }).localId, + this.messaging.models['Message'].findFromIdentifyingData({ id: postedMessageId }).localId, "new message in thread should be linked to newly created message from message post" ); assert.strictEqual( @@ -3106,7 +3106,7 @@ QUnit.test('receive new needaction messages', async function (assert) { ); assert.strictEqual( document.querySelector(`.o_Discuss_thread .o_Message`).dataset.messageLocalId, - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 100 }).localId, + this.messaging.models['Message'].findFromIdentifyingData({ id: 100 }).localId, "should display newly received needaction message" ); @@ -3142,7 +3142,7 @@ QUnit.test('receive new needaction messages', async function (assert) { document.querySelector(` .o_Discuss_thread .o_Message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 100 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 100 }).localId }"] `), "should still display 1st needaction message" @@ -3151,7 +3151,7 @@ QUnit.test('receive new needaction messages', async function (assert) { document.querySelector(` .o_Discuss_thread .o_Message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 101 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 101 }).localId }"] `), "should display 2nd needaction message" @@ -3227,7 +3227,7 @@ QUnit.test('reply to message from inbox (message linked to document)', async fun ); assert.strictEqual( document.querySelector('.o_Message').dataset.messageLocalId, - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 100 }).localId, + this.messaging.models['Message'].findFromIdentifyingData({ id: 100 }).localId, "should display message with ID 100" ); assert.strictEqual( @@ -3277,7 +3277,7 @@ QUnit.test('reply to message from inbox (message linked to document)', async fun ); assert.strictEqual( document.querySelector('.o_Message').dataset.messageLocalId, - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 100 }).localId, + this.messaging.models['Message'].findFromIdentifyingData({ id: 100 }).localId, "should still display message with ID 100 after posting reply" ); assert.notOk( @@ -3486,7 +3486,7 @@ QUnit.test('mark a single message as read should only move this message to "Hist await afterNextRender(() => document.querySelector(` .o_Message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 1 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 1 }).localId }"] `).click() ); @@ -3494,7 +3494,7 @@ QUnit.test('mark a single message as read should only move this message to "Hist await afterNextRender(() => document.querySelector(` .o_Message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 1 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 1 }).localId }"] .o_MessageActionList_actionMarkRead `).click() ); @@ -3506,7 +3506,7 @@ QUnit.test('mark a single message as read should only move this message to "Hist assert.containsOnce( document.body, `.o_Message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 2 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 2 }).localId }"]`, "message still in inbox should be the one not marked as read" ); @@ -3535,7 +3535,7 @@ QUnit.test('mark a single message as read should only move this message to "Hist assert.containsOnce( document.body, `.o_Message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 1 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 1 }).localId }"]`, "message moved in history should be the one marked as read" ); diff --git a/addons/mail/static/src/components/message/tests/message_tests.js b/addons/mail/static/src/components/message/tests/message_tests.js index dda050b6108..d5eeb5e7096 100644 --- a/addons/mail/static/src/components/message/tests/message_tests.js +++ b/addons/mail/static/src/components/message/tests/message_tests.js @@ -39,7 +39,7 @@ QUnit.test('basic rendering', async function (assert) { assert.expect(12); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ author: insert({ id: 7, display_name: "Demo User" }), body: "Test
", date: moment(), @@ -54,7 +54,7 @@ QUnit.test('basic rendering', async function (assert) { const messageEl = document.querySelector('.o_Message'); assert.strictEqual( messageEl.dataset.messageLocalId, - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 100 }).localId, + this.messaging.models['Message'].findFromIdentifyingData({ id: 100 }).localId, "message component should be linked to message store model" ); assert.strictEqual( @@ -294,7 +294,7 @@ QUnit.test("'channel_fetch' notification received is correctly handled", async f qunitTest: insertAndReplace(), thread: link(thread), }); - this.messaging.models['mail.message'].create({ + this.messaging.models['Message'].create({ author: link(currentPartner), body: "Test
", id: 100, @@ -359,7 +359,7 @@ QUnit.test("'channel_seen' notification received is correctly handled", async fu qunitTest: insertAndReplace(), thread: link(thread), }); - this.messaging.models['mail.message'].create({ + this.messaging.models['Message'].create({ author: link(currentPartner), body: "Test
", id: 100, @@ -423,7 +423,7 @@ QUnit.test("'channel_fetch' notification then 'channel_seen' received are corre qunitTest: insertAndReplace(), thread: link(thread), }); - this.messaging.models['mail.message'].create({ + this.messaging.models['Message'].create({ author: link(currentPartner), body: "Test
", id: 100, @@ -506,7 +506,7 @@ QUnit.test('do not show messaging seen indicator if not authored by me', async f qunitTest: insertAndReplace(), thread: link(thread), }); - this.messaging.models['mail.message'].insert({ + this.messaging.models['Message'].insert({ author: link(author), body: "Test
", id: 100, @@ -547,13 +547,13 @@ QUnit.test('do not show messaging seen indicator if before last seen by all mess qunitTest: insertAndReplace(), thread: link(thread), }); - const lastSeenMessage = this.messaging.models['mail.message'].create({ + const lastSeenMessage = this.messaging.models['Message'].create({ author: link(currentPartner), body: "You already saw me
", id: 100, originThread: link(thread), }); - this.messaging.models['mail.message'].insert({ + this.messaging.models['Message'].insert({ author: link(currentPartner), body: "Test
", id: 99, @@ -625,7 +625,7 @@ QUnit.test('only show messaging seen indicator if authored by me, after last see qunitTest: insertAndReplace(), thread: link(thread), }); - this.messaging.models['mail.message'].insert({ + this.messaging.models['Message'].insert({ author: link(currentPartner), body: "Test
", id: 100, @@ -655,7 +655,7 @@ QUnit.test('allow attachment delete on authored message', async function (assert assert.expect(5); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: insertAndReplace({ filename: "BLAH.jpg", id: 10, @@ -705,7 +705,7 @@ QUnit.test('prevent attachment delete on non-authored message', async function ( assert.expect(2); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: insertAndReplace({ filename: "BLAH.jpg", id: 10, @@ -734,7 +734,7 @@ QUnit.test('subtype description should be displayed if it is different than body assert.expect(2); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ body: "Hello
", id: 100, subtype_description: 'Bonjour', @@ -756,7 +756,7 @@ QUnit.test('subtype description should not be displayed if it is similar to body assert.expect(2); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ body: "Hello
", id: 100, subtype_description: 'hello', @@ -797,7 +797,7 @@ QUnit.test('data-oe-id & data-oe-model link redirection on click', async functio assert.step('do-action:openFormView_some.model_250'); }); const { createMessageComponent } = await this.start({ env: { bus } }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ body: ``, id: 100, }); @@ -828,7 +828,7 @@ QUnit.test('chat with author should be opened after clicking on his avatar', asy const { createMessageComponent } = await this.start({ hasChatWindow: true, }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ author: insert({ id: 10 }), id: 10, }); @@ -867,7 +867,7 @@ QUnit.test('chat with author should be opened after clicking on his im status ic const { createMessageComponent } = await this.start({ hasChatWindow: true, }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ author: insert({ id: 10, im_status: 'online' }), id: 10, }); @@ -951,7 +951,7 @@ QUnit.test('basic rendering of tracking value (float type)', async function (ass assert.expect(8); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Total", @@ -1008,7 +1008,7 @@ QUnit.test('rendering of tracked field of type integer: from non-0 to 0', async assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Total", @@ -1030,7 +1030,7 @@ QUnit.test('rendering of tracked field of type integer: from 0 to non-0', async assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Total", @@ -1052,7 +1052,7 @@ QUnit.test('rendering of tracked field of type float: from non-0 to 0', async fu assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Total", @@ -1074,7 +1074,7 @@ QUnit.test('rendering of tracked field of type float: from 0 to non-0', async fu assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Total", @@ -1096,7 +1096,7 @@ QUnit.test('rendering of tracked field of type monetary: from non-0 to 0', async assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Total", @@ -1118,7 +1118,7 @@ QUnit.test('rendering of tracked field of type monetary: from 0 to non-0', async assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Total", @@ -1140,7 +1140,7 @@ QUnit.test('rendering of tracked field of type boolean: from true to false', asy assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Is Ready", @@ -1162,7 +1162,7 @@ QUnit.test('rendering of tracked field of type boolean: from false to true', asy assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Is Ready", @@ -1184,7 +1184,7 @@ QUnit.test('rendering of tracked field of type char: from a string to empty stri assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Name", @@ -1206,7 +1206,7 @@ QUnit.test('rendering of tracked field of type char: from empty string to a stri assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Name", @@ -1228,7 +1228,7 @@ QUnit.test('rendering of tracked field of type date: from no date to a set date' assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Deadline", @@ -1250,7 +1250,7 @@ QUnit.test('rendering of tracked field of type date: from a set date to no date' assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Deadline", @@ -1272,7 +1272,7 @@ QUnit.test('rendering of tracked field of type datetime: from no date and time t assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Deadline", @@ -1294,7 +1294,7 @@ QUnit.test('rendering of tracked field of type datetime: from a set date and tim assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Deadline", @@ -1316,7 +1316,7 @@ QUnit.test('rendering of tracked field of type text: from some text to empty', a assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Name", @@ -1338,7 +1338,7 @@ QUnit.test('rendering of tracked field of type text: from empty to some text', a assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Name", @@ -1360,7 +1360,7 @@ QUnit.test('rendering of tracked field of type selection: from a selection to no assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "State", @@ -1382,7 +1382,7 @@ QUnit.test('rendering of tracked field of type selection: from no selection to a assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "State", @@ -1404,7 +1404,7 @@ QUnit.test('rendering of tracked field of type many2one: from having a related r assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Author", @@ -1426,7 +1426,7 @@ QUnit.test('rendering of tracked field of type many2one: from no related record assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Author", @@ -1454,7 +1454,7 @@ QUnit.test('basic rendering of tracking value (monetary type)', async function ( }, }, }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ id: 11, tracking_value_ids: [{ changed_field: "Revenue", @@ -1513,7 +1513,7 @@ QUnit.test('message should not be considered as "clicked" after clicking on its assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ author: [['insert', { id: 7, display_name: "Demo User" }]], body: "Test
", id: 100, @@ -1532,7 +1532,7 @@ QUnit.test('message should not be considered as "clicked" after clicking on its assert.expect(1); const { createMessageComponent } = await this.start(); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ author: [['insert', { id: 7, display_name: "Demo User" }]], body: "Test
", id: 100, diff --git a/addons/mail/static/src/components/message_author_prefix/message_author_prefix.js b/addons/mail/static/src/components/message_author_prefix/message_author_prefix.js index 429ca0a81bc..afc0945e4b7 100644 --- a/addons/mail/static/src/components/message_author_prefix/message_author_prefix.js +++ b/addons/mail/static/src/components/message_author_prefix/message_author_prefix.js @@ -11,10 +11,10 @@ export class MessageAuthorPrefix extends Component { //-------------------------------------------------------------------------- /** - * @returns {mail.message} + * @returns {Message} */ get message() { - return this.messaging && this.messaging.models['mail.message'].get(this.props.messageLocalId); + return this.messaging && this.messaging.models['Message'].get(this.props.messageLocalId); } /** diff --git a/addons/mail/static/src/components/message_seen_indicator/message_seen_indicator.js b/addons/mail/static/src/components/message_seen_indicator/message_seen_indicator.js index 6a121fd35e3..32e9cef5253 100644 --- a/addons/mail/static/src/components/message_seen_indicator/message_seen_indicator.js +++ b/addons/mail/static/src/components/message_seen_indicator/message_seen_indicator.js @@ -73,10 +73,10 @@ export class MessageSeenIndicator extends Component { } /** - * @returns {mail.message} + * @returns {Message} */ get message() { - return this.messaging && this.messaging.models['mail.message'].get(this.props.messageLocalId); + return this.messaging && this.messaging.models['Message'].get(this.props.messageLocalId); } /** diff --git a/addons/mail/static/src/components/message_seen_indicator/tests/message_seen_indicator_tests.js b/addons/mail/static/src/components/message_seen_indicator/tests/message_seen_indicator_tests.js index eaf77f51a82..43542a256ec 100644 --- a/addons/mail/static/src/components/message_seen_indicator/tests/message_seen_indicator_tests.js +++ b/addons/mail/static/src/components/message_seen_indicator/tests/message_seen_indicator_tests.js @@ -59,7 +59,7 @@ QUnit.test('rendering when just one has received the message', async function (a message: insertAndReplace({ id: 100 }), }), }); - const message = this.messaging.models['mail.message'].insert({ + const message = this.messaging.models['Message'].insert({ author: insert({ id: this.messaging.currentPartner.id, display_name: "Demo User" }), body: "Test
", id: 100, @@ -104,7 +104,7 @@ QUnit.test('rendering when everyone have received the message', async function ( message: insertAndReplace({ id: 100 }), }), }); - const message = this.messaging.models['mail.message'].insert({ + const message = this.messaging.models['Message'].insert({ author: insert({ id: this.messaging.currentPartner.id, display_name: "Demo User" }), body: "Test
", id: 100, @@ -150,7 +150,7 @@ QUnit.test('rendering when just one has seen the message', async function (asser message: insertAndReplace({ id: 100 }), }), }); - const message = this.messaging.models['mail.message'].insert({ + const message = this.messaging.models['Message'].insert({ author: insert({ id: this.messaging.currentPartner.id, display_name: "Demo User" }), body: "Test
", id: 100, @@ -196,7 +196,7 @@ QUnit.test('rendering when just one has seen & received the message', async func message: insertAndReplace({ id: 100 }), }), }); - const message = this.messaging.models['mail.message'].insert({ + const message = this.messaging.models['Message'].insert({ author: insert({ id: this.messaging.currentPartner.id, display_name: "Demo User" }), body: "Test
", id: 100, @@ -244,7 +244,7 @@ QUnit.test('rendering when just everyone has seen the message', async function ( message: insertAndReplace({ id: 100 }), }), }); - const message = this.messaging.models['mail.message'].insert({ + const message = this.messaging.models['Message'].insert({ author: insert({ id: this.messaging.currentPartner.id, display_name: "Demo User" }), body: "Test
", id: 100, diff --git a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.js b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.js index db1217f3b52..68e56026ab5 100644 --- a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.js +++ b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.js @@ -87,7 +87,7 @@ export class ThreadNeedactionPreview extends Component { * @param {MouseEvent} ev */ _onClickMarkAsRead(ev) { - this.messaging.models['mail.message'].markAllAsRead([ + this.messaging.models['Message'].markAllAsRead([ ['model', '=', this.thread.model], ['res_id', '=', this.thread.id], ]); diff --git a/addons/mail/static/src/components/thread_view/tests/thread_view_tests.js b/addons/mail/static/src/components/thread_view/tests/thread_view_tests.js index ec3f515daeb..7bdee2b0824 100644 --- a/addons/mail/static/src/components/thread_view/tests/thread_view_tests.js +++ b/addons/mail/static/src/components/thread_view/tests/thread_view_tests.js @@ -648,7 +648,7 @@ QUnit.test('new messages separator on receiving new message [REQUIRE FOCUS]', as assert.containsOnce( document.body, `.o_MessageList_separatorNewMessages ~ .o_Message[data-message-local-id="${ - this.messaging.models['mail.message'].findFromIdentifyingData({ id: 2 }).localId + this.messaging.models['Message'].findFromIdentifyingData({ id: 2 }).localId }"]`, "'new messages' separator should be shown above new message received" ); @@ -1815,7 +1815,7 @@ QUnit.test('first unseen message should be directly preceded by the new message assert.containsOnce( document.body, `.o_Message[data-message-local-id="${ - this.messaging.models['mail.message'].find(m => m.isTransient).localId + this.messaging.models['Message'].find(m => m.isTransient).localId }"] + .o_MessageList_separatorNewMessages`, "separator should be shown just after transient message" ); diff --git a/addons/mail/static/src/models/attachment/attachment.js b/addons/mail/static/src/models/attachment/attachment.js index 9d6b19e4fad..b25a254fbc0 100644 --- a/addons/mail/static/src/models/attachment/attachment.js +++ b/addons/mail/static/src/models/attachment/attachment.js @@ -391,7 +391,7 @@ registerModel({ mediaType: attr({ compute: '_computeMediaType', }), - messages: many2many('mail.message', { + messages: many2many('Message', { inverse: 'attachments', }), mimetype: attr({ diff --git a/addons/mail/static/src/models/attachment_list/attachment_list.js b/addons/mail/static/src/models/attachment_list/attachment_list.js index a71334bf6fa..10df15719d8 100644 --- a/addons/mail/static/src/models/attachment_list/attachment_list.js +++ b/addons/mail/static/src/models/attachment_list/attachment_list.js @@ -107,7 +107,7 @@ registerModel({ imageAttachments: many2many('mail.attachment', { compute: '_computeImageAttachments', }), - message: many2one('mail.message', { + message: many2one('Message', { related: 'messageView.message' }), /** diff --git a/addons/mail/static/src/models/chatter/chatter.js b/addons/mail/static/src/models/chatter/chatter.js index 17851ef732f..47be59ee60a 100644 --- a/addons/mail/static/src/models/chatter/chatter.js +++ b/addons/mail/static/src/models/chatter/chatter.js @@ -224,7 +224,7 @@ registerModel({ } } else if (!this.thread || !this.thread.isTemporary) { const currentPartner = this.messaging.currentPartner; - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ author: link(currentPartner), body: this.env._t("Creating a new record..."), id: getMessageNextTemporaryId(), diff --git a/addons/mail/static/src/models/composer_view/composer_view.js b/addons/mail/static/src/models/composer_view/composer_view.js index cc85b8b7837..0ccf88933ad 100644 --- a/addons/mail/static/src/models/composer_view/composer_view.js +++ b/addons/mail/static/src/models/composer_view/composer_view.js @@ -293,8 +293,8 @@ registerModel({ if (!this.messaging) { return; } - const message = this.messaging.models['mail.message'].insert( - this.messaging.models['mail.message'].convertData(messageData) + const message = this.messaging.models['Message'].insert( + this.messaging.models['Message'].convertData(messageData) ); for (const threadView of message.originThread.threadViews) { // Reset auto scroll to be able to see the newly posted message. diff --git a/addons/mail/static/src/models/guest/guest.js b/addons/mail/static/src/models/guest/guest.js index fcd0a9268cc..b7502d6e5c0 100644 --- a/addons/mail/static/src/models/guest/guest.js +++ b/addons/mail/static/src/models/guest/guest.js @@ -32,7 +32,7 @@ registerModel({ }, }, fields: { - authoredMessages: one2many('mail.message', { + authoredMessages: one2many('Message', { inverse: 'guestAuthor', }), avatarUrl: attr({ diff --git a/addons/mail/static/src/models/message/message.js b/addons/mail/static/src/models/message/message.js index a9325590622..e2051776f50 100644 --- a/addons/mail/static/src/models/message/message.js +++ b/addons/mail/static/src/models/message/message.js @@ -11,7 +11,7 @@ import { session } from '@web/session'; import { str_to_datetime } from 'web.time'; registerModel({ - name: 'mail.message', + name: 'Message', identifyingFields: ['id'], modelMethods: { /** @@ -148,7 +148,7 @@ registerModel({ * * @see MessagingNotificationHandler:_handleNotificationPartnerMarkAsRead() * - * @param {mail.message[]} messages + * @param {Message[]} messages */ async markAsRead(messages) { await this.env.services.rpc({ @@ -162,15 +162,15 @@ registerModel({ * * @param {string} route * @param {Object} params - * @returns {mail.message[]} + * @returns {Message[]} */ async performRpcMessageFetch(route, params) { const messagesData = await this.env.services.rpc({ route, params }, { shadow: true }); if (!this.messaging) { return; } - const messages = this.messaging.models['mail.message'].insert(messagesData.map( - messageData => this.messaging.models['mail.message'].convertData(messageData) + const messages = this.messaging.models['Message'].insert(messagesData.map( + messageData => this.messaging.models['Message'].convertData(messageData) )); // compute seen indicators (if applicable) for (const message of messages) { @@ -287,7 +287,7 @@ registerModel({ if (!this.messaging) { return; } - this.messaging.models['mail.message'].insert(messageData); + this.messaging.models['Message'].insert(messageData); }, /** * @returns {string|FieldCommand} @@ -725,7 +725,7 @@ registerModel({ * (parent_id in python) that should be ignored for the purpose of this * feature. */ - parentMessage: many2one('mail.message'), + parentMessage: many2one('Message'), /** * This value is meant to be based on field body which is * returned by the server (and has been sanitized before stored into db). diff --git a/addons/mail/static/src/models/message/tests/message_tests.js b/addons/mail/static/src/models/message/tests/message_tests.js index ba16735b230..c4ec3692572 100644 --- a/addons/mail/static/src/models/message/tests/message_tests.js +++ b/addons/mail/static/src/models/message/tests/message_tests.js @@ -35,14 +35,14 @@ QUnit.test('create', async function (assert) { model: 'mail.channel', })); assert.notOk(this.messaging.models['mail.attachment'].findFromIdentifyingData({ id: 750 })); - assert.notOk(this.messaging.models['mail.message'].findFromIdentifyingData({ id: 4000 })); + assert.notOk(this.messaging.models['Message'].findFromIdentifyingData({ id: 4000 })); const thread = this.messaging.models['Thread'].create({ id: 100, model: 'mail.channel', name: "General", }); - const message = this.messaging.models['mail.message'].create({ + const message = this.messaging.models['Message'].create({ attachments: insertAndReplace({ filename: "test.txt", id: 750, @@ -64,10 +64,10 @@ QUnit.test('create', async function (assert) { model: 'mail.channel', })); assert.ok(this.messaging.models['mail.attachment'].findFromIdentifyingData({ id: 750 })); - assert.ok(this.messaging.models['mail.message'].findFromIdentifyingData({ id: 4000 })); + assert.ok(this.messaging.models['Message'].findFromIdentifyingData({ id: 4000 })); assert.ok(message); - assert.strictEqual(this.messaging.models['mail.message'].findFromIdentifyingData({ id: 4000 }), message); + assert.strictEqual(this.messaging.models['Message'].findFromIdentifyingData({ id: 4000 }), message); assert.strictEqual(message.body, "Test
"); assert.ok(message.date instanceof moment); assert.strictEqual( @@ -113,70 +113,70 @@ QUnit.test('create', async function (assert) { QUnit.test('message without body should be considered empty', async function (assert) { assert.expect(1); await this.start(); - const message = this.messaging.models['mail.message'].create({ id: 11 }); + const message = this.messaging.models['Message'].create({ id: 11 }); assert.ok(message.isEmpty); }); QUnit.test('message with body "" should be considered empty', async function (assert) { assert.expect(1); await this.start(); - const message = this.messaging.models['mail.message'].create({ body: "", id: 11 }); + const message = this.messaging.models['Message'].create({ body: "", id: 11 }); assert.ok(message.isEmpty); }); QUnit.test('message with body "" should be considered empty', async function (assert) { assert.expect(1); await this.start(); - const message = this.messaging.models['mail.message'].create({ body: "", id: 11 }); + const message = this.messaging.models['Message'].create({ body: "", id: 11 }); assert.ok(message.isEmpty); }); QUnit.test('message with body "\n
" should be considered empty`, async function (assert) { assert.expect(1); await this.start(); - const message = this.messaging.models['mail.message'].create({ body: "\n
", id: 11 }); + const message = this.messaging.models['Message'].create({ body: "\n
", id: 11 }); assert.ok(message.isEmpty); }); QUnit.test(String.raw`message with body "\r\n\r\n
" should be considered empty`, async function (assert) { assert.expect(1); await this.start(); - const message = this.messaging.models['mail.message'].create({ body: "\r\n\r\n
", id: 11 }); + const message = this.messaging.models['Message'].create({ body: "\r\n\r\n
", id: 11 }); assert.ok(message.isEmpty); }); QUnit.test('message with body "" should be considered empty', async function (assert) { assert.expect(1); await this.start(); - const message = this.messaging.models['mail.message'].create({ body: "
", id: 11 }); + const message = this.messaging.models['Message'].create({ body: "
", id: 11 }); assert.ok(message.isEmpty); }); QUnit.test(`message with body "