diff options
| author | Sébastien Theys <seb@odoo.com> | 2021-01-22 17:10:29 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2021-01-22 17:10:29 +0000 |
| commit | 12f11e0daf7e459bfee518b312e144d78e5a5759 (patch) | |
| tree | 6d1a65755c2ee8e9df43d6da5ded087efb030cde /addons/mail/static/src/components/thread_needaction_preview | |
| parent | 86333160f92c16bc61f36b413caed325f8ac59a0 (diff) | |
[FIX] mail: fix inbox mark all as read on thread view
task-2426357
task-2426366
closes odoo/odoo#64009
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/thread_needaction_preview')
2 files changed, 29 insertions, 11 deletions
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 eb520560d96..b70c8f6b99a 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 @@ -119,7 +119,6 @@ class ThreadNeedactionPreview extends Component { // handled in `_onClickMarkAsRead` return; } - this.thread.markNeedactionMessagesAsOriginThreadAsRead(); this.thread.open(); if (!this.env.messaging.device.isMobile) { this.env.messaging.messagingMenu.close(); @@ -131,7 +130,10 @@ class ThreadNeedactionPreview extends Component { * @param {MouseEvent} ev */ _onClickMarkAsRead(ev) { - this.thread.markNeedactionMessagesAsOriginThreadAsRead(); + this.env.models['mail.message'].markAllAsRead([ + ['model', '=', this.thread.model], + ['res_id', '=', this.thread.id], + ]); } } diff --git a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview_tests.js b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview_tests.js index f3e1d49148b..ca1fe22c785 100644 --- a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview_tests.js +++ b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview_tests.js @@ -44,7 +44,7 @@ QUnit.module('thread_needaction_preview_tests.js', { }); QUnit.test('mark as read', async function (assert) { - assert.expect(4); + assert.expect(5); this.data['mail.message'].records.push({ id: 21, @@ -63,8 +63,16 @@ QUnit.test('mark as read', async function (assert) { hasChatWindow: true, hasMessagingMenu: true, async mockRPC(route, args) { - if (route.includes('set_message_done')) { - assert.step('set_message_done'); + if (route.includes('mark_all_as_read')) { + assert.step('mark_all_as_read'); + assert.deepEqual( + args.kwargs.domain, + [ + ['model', '=', 'res.partner'], + ['res_id', '=', 11], + ], + "should mark all as read the correct thread" + ); } return this._super(...arguments); }, @@ -87,8 +95,8 @@ QUnit.test('mark as read', async function (assert) { document.querySelector('.o_ThreadNeedactionPreview_markAsRead').click() ); assert.verifySteps( - ['set_message_done'], - "should have marked the message as read" + ['mark_all_as_read'], + "should have marked the thread as read" ); assert.containsNone( document.body, @@ -98,7 +106,7 @@ QUnit.test('mark as read', async function (assert) { }); QUnit.test('click on preview should mark as read and open the thread', async function (assert) { - assert.expect(5); + assert.expect(6); this.data['mail.message'].records.push({ id: 21, @@ -117,8 +125,16 @@ QUnit.test('click on preview should mark as read and open the thread', async fun hasChatWindow: true, hasMessagingMenu: true, async mockRPC(route, args) { - if (route.includes('set_message_done')) { - assert.step('set_message_done'); + if (route.includes('mark_all_as_read')) { + assert.step('mark_all_as_read'); + assert.deepEqual( + args.kwargs.domain, + [ + ['model', '=', 'res.partner'], + ['res_id', '=', 11], + ], + "should mark all as read the correct thread" + ); } return this._super(...arguments); }, @@ -146,7 +162,7 @@ QUnit.test('click on preview should mark as read and open the thread', async fun document.querySelector('.o_ThreadNeedactionPreview').click() ); assert.verifySteps( - ['set_message_done'], + ['mark_all_as_read'], "should have marked the message as read on clicking on the preview" ); assert.containsOnce( |
