[FIX] mail: chatter notif opens view even when discuss app is open
Clicking on chatter notification from the messaging menu should either open chat window or form view, depending on whether the discuss app is closed or open respectively. Before this commit, when discuss app was open and user clicks on messaging menu item related to chatter notification, it was opening the chatter in discuss app. Although it works, some features seem missing, such as lack of chatter-specific features, and missing entry in the app sidebar. The discuss app is designed to work only on `discuss.channel` threads, therefore chatter threads should never be shown inside this app. This commit fixes the issue by ensuring that all opening of chatters from the discuss app opens the form view. closes odoo/odoo#128809 X-original-commit: 94c12dd231212e2e52b626a380344623c8627d7c Signed-off-by: Sébastien Theys (seb) <seb@odoo.com> Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -35,16 +35,7 @@ patch(Message.prototype, "mail/core/web", {
|
||||
}
|
||||
},
|
||||
openRecord() {
|
||||
if (this.message.resModel === "discuss.channel") {
|
||||
this.threadService.open(this.message.originThread);
|
||||
} else {
|
||||
this.action.doAction({
|
||||
type: "ir.actions.act_window",
|
||||
res_id: this.message.resId,
|
||||
res_model: this.message.resModel,
|
||||
views: [[false, "form"]],
|
||||
});
|
||||
}
|
||||
this.threadService.open(this.message.originThread);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@ let nextId = 1;
|
||||
patch(ThreadService.prototype, "mail/core/web", {
|
||||
setup(env, services) {
|
||||
this._super(env, services);
|
||||
this.action = services.action;
|
||||
/** @type {import("@mail/core/common/attachment_service").AttachmentService} */
|
||||
this.attachmentService = services["mail.attachment"];
|
||||
/** @type {import("@mail/core/web/activity_service").ActivityService} */
|
||||
@@ -199,8 +200,22 @@ patch(ThreadService.prototype, "mail/core/web", {
|
||||
}
|
||||
},
|
||||
open(thread, replaceNewMessageChatWindow) {
|
||||
if (!this.store.discuss.isActive || this.ui.isSmall) {
|
||||
this.chatWindowService.open(thread, replaceNewMessageChatWindow);
|
||||
if (!this.store.discuss.isActive && !this.ui.isSmall) {
|
||||
this._openChatWindow(thread, replaceNewMessageChatWindow);
|
||||
return;
|
||||
}
|
||||
if (this.ui.isSmall && thread.model === "discuss.channel") {
|
||||
this._openChatWindow(thread, replaceNewMessageChatWindow);
|
||||
return;
|
||||
}
|
||||
if (thread.model !== "discuss.channel") {
|
||||
this.action.doAction({
|
||||
type: "ir.actions.act_window",
|
||||
res_id: thread.id,
|
||||
res_model: thread.model,
|
||||
views: [[false, "form"]],
|
||||
});
|
||||
return;
|
||||
}
|
||||
this._super(thread, replaceNewMessageChatWindow);
|
||||
},
|
||||
@@ -227,11 +242,24 @@ patch(ThreadService.prototype, "mail/core/web", {
|
||||
}
|
||||
this._super(...arguments);
|
||||
},
|
||||
_openChatWindow(thread, replaceNewMessageChatWindow) {
|
||||
const chatWindow = this.chatWindowService.insert({
|
||||
folded: false,
|
||||
thread,
|
||||
replaceNewMessageChatWindow,
|
||||
});
|
||||
chatWindow.autofocus++;
|
||||
if (thread) {
|
||||
thread.state = "open";
|
||||
}
|
||||
this.chatWindowService.notifyState(chatWindow);
|
||||
},
|
||||
});
|
||||
|
||||
patch(threadService, "mail/core/web", {
|
||||
dependencies: [
|
||||
...threadService.dependencies,
|
||||
"action",
|
||||
"mail.activity",
|
||||
"mail.attachment",
|
||||
"mail.chat_window",
|
||||
|
||||
@@ -1835,3 +1835,36 @@ QUnit.test(
|
||||
assert.strictEqual($(".o_breadcrumb").text(), "DiscussGeneral");
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"Chatter notification in messaging menu should open the form view even when discuss app is open",
|
||||
async (assert) => {
|
||||
const pyEnv = await startServer();
|
||||
const partnerId = pyEnv["res.partner"].create({ name: "TestPartner" });
|
||||
const messageId = pyEnv["mail.message"].create({
|
||||
model: "res.partner",
|
||||
body: "A needaction message to have it in messaging menu",
|
||||
author_id: pyEnv.odoobotId,
|
||||
needaction: true,
|
||||
needaction_partner_ids: [pyEnv.currentPartnerId],
|
||||
res_id: partnerId,
|
||||
});
|
||||
pyEnv["mail.notification"].create({
|
||||
mail_message_id: messageId,
|
||||
notification_status: "sent",
|
||||
notification_type: "inbox",
|
||||
res_partner_id: pyEnv.currentPartnerId,
|
||||
});
|
||||
const { openDiscuss } = await start();
|
||||
await openDiscuss();
|
||||
await click(".o_main_navbar i[aria-label='Messages']");
|
||||
await click(".o-mail-NotificationItem");
|
||||
assert.containsNone($, ".o-mail-Discuss");
|
||||
assert.containsOnce($, ".o_form_view .o-mail-Chatter");
|
||||
assert.containsOnce($, ".o_form_view .o_breadcrumb:contains(TestPartner)");
|
||||
assert.containsOnce(
|
||||
$,
|
||||
".o-mail-Chatter .o-mail-Message:contains(A needaction message to have it in messaging menu)"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user