[FIX] mail: open inbox on preview click not linked to any document
Before this commit, when the user clicked on a preview in the systray messaging menu that is not linked to any document, there was a traceback. Steps to reproduce: - Admin sets notification management to "Handle with Odoo" - Demo user assigns Admin to a task - Admin clicks on preview from being assigned to a task Those are previews from notifications received from the inbox, which are not related to any document. It attempts to open a document that does not exists (i.e. no model/id). With this commit, when such a preview is not linked to any document, it now opens Discuss with Inbox. Task-ID 1891350
This commit is contained in:
@@ -282,7 +282,11 @@ var MessagingMenu = Widget.extend({
|
||||
// e.g. needaction message of channel
|
||||
var documentID = $target.data('document-id');
|
||||
var documentModel = $target.data('document-model');
|
||||
this._openDocument(documentModel, documentID);
|
||||
if (!documentModel) {
|
||||
this._openDiscuss('mailbox_inbox');
|
||||
} else {
|
||||
this._openDocument(documentModel, documentID);
|
||||
}
|
||||
} else {
|
||||
// preview of thread
|
||||
this.call('mail_service', 'openThread', previewID);
|
||||
|
||||
@@ -146,8 +146,8 @@ QUnit.test('messaging menu widget: messaging menu with 1 record', function (asse
|
||||
messagingMenu.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('messaging menu widget: no crash when clicking on inbox notification not associated to a document', function (assert) {
|
||||
assert.expect(3);
|
||||
QUnit.test('messaging menu widget: open inbox for needaction not linked to any document', function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
var messagingMenu = new MessagingMenu();
|
||||
testUtils.addMockEnvironment(messagingMenu, {
|
||||
@@ -156,17 +156,6 @@ QUnit.test('messaging menu widget: no crash when clicking on inbox notification
|
||||
session: {
|
||||
partner_id: 1,
|
||||
},
|
||||
intercepts: {
|
||||
/**
|
||||
* Simulate action 'mail.action_discuss' successfully performed.
|
||||
*
|
||||
* @param {OdooEvent} ev
|
||||
* @param {function} ev.data.on_success called when success action performed
|
||||
*/
|
||||
do_action: function (ev) {
|
||||
ev.data.on_success();
|
||||
},
|
||||
},
|
||||
});
|
||||
messagingMenu.appendTo($('#qunit-fixture'));
|
||||
|
||||
@@ -195,12 +184,18 @@ QUnit.test('messaging menu widget: no crash when clicking on inbox notification
|
||||
assert.strictEqual($firstChannelPreview.data('preview-id'),
|
||||
'mailbox_inbox',
|
||||
"should be a preview from channel inbox");
|
||||
try {
|
||||
$firstChannelPreview.click();
|
||||
assert.ok(true, "should not have crashed when clicking on needaction preview message");
|
||||
} finally {
|
||||
messagingMenu.destroy();
|
||||
}
|
||||
|
||||
testUtils.intercept(messagingMenu, 'do_action', function (ev) {
|
||||
if (ev.data.action === 'mail.action_discuss') {
|
||||
assert.step('do_action:' + ev.data.action + ':' + ev.data.options.active_id);
|
||||
}
|
||||
}, true);
|
||||
$firstChannelPreview.click();
|
||||
assert.verifySteps(
|
||||
['do_action:mail.action_discuss:mailbox_inbox'],
|
||||
"should open Discuss with Inbox");
|
||||
|
||||
messagingMenu.destroy();
|
||||
});
|
||||
|
||||
QUnit.test("messaging menu widget: mark as read on thread preview", function ( assert ) {
|
||||
|
||||
Reference in New Issue
Block a user