初始提交

This commit is contained in:
2026-11-04 19:58:07 +08:00
commit 53b7d22429
829 changed files with 469986 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
// Align with `o_form_statusbar` in enterprise
.o-mail-Form-chatter.o-aside {
--Chatter-top-padding-top: 0;
}

View File

@@ -0,0 +1,6 @@
declare module "models" {
export interface Settings {
color_scheme: "light"|"dark";
homemenu_config: string;
}
}

View File

@@ -0,0 +1,9 @@
.o-discuss-badge {
&, & .o-innerBadge {
--o-discuss-badge-bg: #{$o-danger}; // sync with --o-navbar-badge-bg
}
}
.o-mail-DiscussSearch {
--DiscussSearch-padding-top: 0;
}

View File

@@ -0,0 +1,7 @@
import { patch } from "@web/core/utils/patch";
import { Message } from "@mail/core/common/message";
patch(Message, {
SHADOW_LINK_COLOR: "#017e84",
SHADOW_LINK_HOVER_COLOR: "#016b70",
});

View File

@@ -0,0 +1,15 @@
import { Settings } from "@mail/core/common/settings_model";
import { patch } from "@web/core/utils/patch";
// web_enterprise columns of the settings row: declared here as mail_enterprise
// is the mail <-> web_enterprise bridge
patch(Settings.prototype, {
setup() {
super.setup();
/** @type {"light"|"dark"} */
this.color_scheme = undefined;
/** @type {string} JSON of the home menu ordering */
this.homemenu_config = undefined;
},
});

View File

@@ -0,0 +1,27 @@
import { registry } from "@web/core/registry";
import {
Many2ManyTagsAvatarUserField,
many2ManyTagsAvatarUserField,
} from "@mail/views/web/fields/many2many_avatar_user_field/many2many_avatar_user_field";
/**
* Hide the members if we already show them in the responsible list.
*/
export class Many2manyTagsResGroupUsers extends Many2ManyTagsAvatarUserField {
get tags() {
const responsibles = this.props.record.data.responsible_ids.records;
const responsibleIds = responsibles.map((r) => r._config.resId);
const records = this.props.record.data[this.props.name].records;
const resIdToId = Object.fromEntries(records.map((r) => [r.id, r._config.resId]));
return super.tags.filter((r) => !responsibleIds.includes(resIdToId[r.id]));
}
}
registry.category("fields").add("many2many_tags_res_group_users", {
...many2ManyTagsAvatarUserField,
fieldDependencies: [
{ name: "responsible_ids", type: "many2many" },
...(many2ManyTagsAvatarUserField.fieldDependencies || []),
],
component: Many2manyTagsResGroupUsers,
});

View File

@@ -0,0 +1,11 @@
import { ChatWindow } from "@mail/core/common/chat_window";
import { useService } from "@web/core/utils/hooks";
import { patch } from "@web/core/utils/patch";
patch(ChatWindow.prototype, {
setup() {
super.setup();
this.homeMenuService = useService("home_menu");
},
});

View File

@@ -0,0 +1,33 @@
import {
click,
contains,
defineMailModels,
openFormView,
start,
startServer,
} from "@mail/../tests/mail_test_helpers";
import { describe, test } from "@odoo/hoot";
import { getMockEnv, patchWithCleanup } from "@web/../tests/web_test_helpers";
import { user } from "@web/core/user";
describe.current.tags("desktop");
defineMailModels();
test("system users are offered to install Odoo Phone from a call activity", async () => {
patchWithCleanup(user, { isSystem: true });
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({});
pyEnv["mail.activity"].create({
phone: "+1 202 555 0182",
res_id: partnerId,
res_model: "res.partner",
});
await start();
patchWithCleanup(getMockEnv().services, { voip: undefined });
await openFormView("res.partner", partnerId);
await click(".o-mail-Activity-call");
await contains(".o_phone_install_dialog");
});

View File

@@ -0,0 +1,87 @@
import {
click,
contains,
defineMailModels,
openDiscuss,
openFormView,
patchUiSize,
SIZES,
start,
startServer,
MENU_ACTIVE_IDS,
} from "@mail/../tests/mail_test_helpers";
import { describe, expect, test } from "@odoo/hoot";
import { patchWithCleanup } from "@web/../tests/web_test_helpers";
import { methods } from "@web_mobile/js/services/core";
import { mockUserAgent } from "@odoo/hoot-mock";
describe.current.tags("mobile");
defineMailModels();
test("'backbutton' event should close attachment viewer", async () => {
patchWithCleanup(methods, {
overrideBackButton({ enabled }) {},
});
mockUserAgent("android");
patchUiSize({ size: SIZES.SM });
const pyEnv = await startServer();
const channelId = pyEnv["discuss.channel"].create({
channel_type: "channel",
name: "channel",
});
const attachmentId = pyEnv["ir.attachment"].create({
name: "test.png",
mimetype: "image/png",
});
pyEnv["mail.message"].create({
attachment_ids: [attachmentId],
body: "<p>Test</p>",
model: "discuss.channel",
res_id: channelId,
});
await start();
await openDiscuss(MENU_ACTIVE_IDS.CHANNEL);
await click(".o-mail-NotificationItem:has(:text('channel'))");
await click(".o-mail-AttachmentImage");
await contains(".o-FileViewer");
const backButtonEvent = new Event("backbutton");
document.dispatchEvent(backButtonEvent);
await contains(".o-FileViewer", { count: 0 });
});
test("[technical] attachment viewer should properly override the back button", async () => {
// simulate the feature is available on the current device
// component must and will be destroyed before the overrideBackButton is unpatched
let overrideBackButton = false;
patchWithCleanup(methods, {
overrideBackButton({ enabled }) {
overrideBackButton = enabled;
},
});
mockUserAgent("android");
patchUiSize({ size: SIZES.SM });
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({ name: "partner 1" });
const messageAttachmentId = pyEnv["ir.attachment"].create({
name: "test.png",
mimetype: "image/png",
});
pyEnv["mail.message"].create({
attachment_ids: [messageAttachmentId],
body: "<p>Test</p>",
model: "res.partner",
res_id: partnerId,
});
await start();
await openFormView("res.partner", partnerId);
await click(".o-mail-AttachmentImage");
await contains(".o-FileViewer");
expect(overrideBackButton).toBe(true);
await click(".o-FileViewer div[aria-label='Close']");
await contains(".o-FileViewer", { count: 0 });
expect(overrideBackButton).toBe(false);
});

View File

@@ -0,0 +1,70 @@
import {
click,
contains,
defineMailModels,
openMessagingMenu,
patchUiSize,
SIZES,
setupChatHub,
start,
startServer,
MENU_ACTIVE_IDS,
} from "@mail/../tests/mail_test_helpers";
import { describe, expect, test } from "@odoo/hoot";
import { patchWithCleanup } from "@web/../tests/web_test_helpers";
import { methods } from "@web_mobile/js/services/core";
import { mockUserAgent } from "@odoo/hoot-mock";
describe.current.tags("mobile");
defineMailModels();
test("'backbutton' event should close chat window", async () => {
mockUserAgent("android");
patchUiSize({ size: SIZES.SM });
// simulate the feature is available on the current device
// component must and will be destroyed before the overrideBackButton is unpatched
patchWithCleanup(methods, {
overrideBackButton({ enabled }) {},
});
const pyEnv = await startServer();
const channelId = pyEnv["discuss.channel"].create({});
setupChatHub({ opened: [channelId] });
await start();
await contains(".o-mail-ChatWindow");
// simulate 'backbutton' event triggered by the mobile app
const backButtonEvent = new Event("backbutton");
document.dispatchEvent(backButtonEvent);
await contains(".o-mail-ChatWindow", { count: 0 });
});
test("[technical] chat window should properly override the back button", async () => {
mockUserAgent("android");
patchUiSize({ size: SIZES.SM });
// simulate the feature is available on the current device
// component must and will be destroyed before the overrideBackButton is unpatched
let overrideBackButton = false;
patchWithCleanup(methods, {
overrideBackButton({ enabled }) {
overrideBackButton = enabled;
},
});
const pyEnv = await startServer();
pyEnv["discuss.channel"].create({ name: "test" });
patchUiSize({ size: SIZES.SM });
await start();
await openMessagingMenu(MENU_ACTIVE_IDS.CHANNEL);
await click(".o-mail-NotificationItem", { text: "test" });
await contains(".o-mail-ChatWindow");
await contains(".o-mail-MessagingMenu", { count: 0 });
expect(overrideBackButton).toBe(true);
await click(".o-mail-ChatWindow [title*='Close']");
await contains(".o-mail-MessagingMenu");
// The messaging menu is re-open when a chat window is closed,
// so we need to close it because it overrides the back button too.
// As long as something overrides the back button, it can't be disabled.
await click(".o_menu_systray i[aria-label='Messages']");
await contains(".o-mail-ChatWindow", { count: 0 });
await contains(".o-mail-MessagingMenu", { count: 0 });
expect(overrideBackButton).toBe(false);
});

View File

@@ -0,0 +1,99 @@
import {
click,
contains,
defineMailModels,
insertText,
openFormView,
patchUiSize,
registerArchs,
scroll,
SIZES,
start,
startServer,
} from "@mail/../tests/mail_test_helpers";
import { beforeEach, describe, test } from "@odoo/hoot";
import { range } from "@web/core/utils/numbers";
describe.current.tags("desktop");
defineMailModels();
beforeEach(() => patchUiSize({ size: SIZES.XXL }));
test("Message list loads new messages on scroll", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({
display_name: "Partner 11",
description: range(61).join("\n"),
});
pyEnv["mail.message"].create(
range(60).map(() => ({
body: "<p>not empty</p>",
model: "res.partner",
res_id: partnerId,
}))
);
registerArchs({
"res.partner,false,form": `
<form string="Partners">
<sheet>
<field name="name"/>
<field name="description"/>
</sheet>
<chatter/>
</form>`,
});
await start();
await openFormView("res.partner", partnerId);
await contains(".o-mail-Message", { count: 30 });
await scroll(".o-mail-Chatter", "bottom");
await contains(".o-mail-Message", { count: 60 });
});
test("Message list is scrolled to new message after posting a message", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({
activity_ids: [],
display_name: "<p>Partner 11</p>",
description: range(60).join("\n"),
message_ids: [],
message_follower_ids: [],
});
pyEnv["mail.message"].create(
range(60).map(() => ({
body: "<p>not empty</p>",
model: "res.partner",
res_id: partnerId,
}))
);
registerArchs({
"res.partner,false,form": `
<form string="Partners">
<header>
<button name="primaryButton" string="Primary" type="object" class="oe_highlight"/>
</header>
<sheet>
<field name="name"/>
<field name="description"/>
</sheet>
<chatter reload_on_post="True" reload_on_attachment="True"/>
</form>`,
});
await start();
await openFormView("res.partner", partnerId);
await contains(".o-mail-Message", { count: 30 });
await contains(".o-mail-Form-chatter.o-aside");
await scroll(".o_content", 0);
await scroll(".o-mail-Chatter", 0);
await scroll(".o-mail-Chatter", "bottom");
await contains(".o-mail-Message", { count: 60 });
await scroll(".o_content", 0);
await click("button", { text: "Log note" });
await insertText(".o-mail-Composer-input", "New Message");
await click(".o-mail-Composer-send:enabled");
await contains(".o-mail-Composer-input", { count: 0 });
await contains(".o-mail-Message", { count: 61 });
await contains(".o-mail-Message-content", { text: "New Message" });
await scroll(".o_content", 0);
await scroll(".o-mail-Chatter", 0);
});

View File

@@ -0,0 +1,55 @@
import {
click,
contains,
defineMailModels,
patchUiSize,
SIZES,
start,
} from "@mail/../tests/mail_test_helpers";
import { describe, expect, test } from "@odoo/hoot";
import { patchWithCleanup } from "@web/../tests/web_test_helpers";
import { methods } from "@web_mobile/js/services/core";
import { mockUserAgent } from "@odoo/hoot-mock";
describe.current.tags("mobile");
defineMailModels();
test("'backbutton' event should close messaging menu", async () => {
mockUserAgent("android");
patchUiSize({ size: SIZES.SM });
// simulate the feature is available on the current device
// component must and will be destroyed before the overrideBackButton is unpatched
patchWithCleanup(methods, {
overrideBackButton({ enabled }) {},
});
await start();
await click(".o_menu_systray i[aria-label='Messages']");
await contains(".o-mail-MessagingMenu");
// simulate 'backbutton' event triggered by the mobile app
const backButtonEvent = new Event("backbutton");
document.dispatchEvent(backButtonEvent);
await contains(".o-mail-MessagingMenu", { count: 0 });
});
test("[technical] messaging menu should properly override the back button", async () => {
mockUserAgent("android");
patchUiSize({ size: SIZES.SM });
// simulate the feature is available on the current device
// component must and will be destroyed before the overrideBackButton is unpatched
let overrideBackButton = false;
patchWithCleanup(methods, {
overrideBackButton({ enabled }) {
overrideBackButton = enabled;
},
});
await start();
await click(".o_menu_systray i[aria-label='Messages']");
await contains(".o-mail-MessagingMenu");
expect(overrideBackButton).toBe(true);
await click(".o_menu_systray i[aria-label='Messages']");
await contains(".o-mail-MessagingMenu", { count: 0 });
expect(overrideBackButton).toBe(false);
});

View File

@@ -0,0 +1,44 @@
import {
contains,
defineMailModels,
openFormView,
patchUiSize,
scroll,
SIZES,
start,
startServer,
} from "@mail/../tests/mail_test_helpers";
import { describe, expect, test } from "@odoo/hoot";
import { waitFor } from "@odoo/hoot-dom";
describe.current.tags("desktop");
defineMailModels();
test("message list desc order", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({ name: "partner 1" });
for (let i = 0; i <= 60; i++) {
pyEnv["mail.message"].create({
body: "not empty",
model: "res.partner",
res_id: partnerId,
});
}
patchUiSize({ size: SIZES.XXL });
await start();
await openFormView("res.partner", partnerId);
const messageEl = await waitFor(".o-mail-Message");
const loadMoreButton = await waitFor("button:contains(Load More)");
const siblings = [...messageEl.parentElement.children];
expect(siblings.indexOf(messageEl)).toBeLessThan(siblings.indexOf(loadMoreButton), {
message: "load more link should be after messages",
});
await contains(".o-mail-Message", { count: 30 });
await scroll(".o-mail-Chatter", "bottom");
await contains(".o-mail-Message", { count: 60 });
await scroll(".o-mail-Chatter", 0);
// weak test, no guaranteed that we waited long enough for potential extra messages to be loaded
await contains(".o-mail-Message", { count: 60 });
});

View File

@@ -0,0 +1,41 @@
import { registry } from "@web/core/registry";
/**
* This tour depends on data created by python test in charge of launching it.
* It is not intended to work when launched from interface. It is needed to test
* an action (action manager) which is not possible to test with QUnit.
* @see mail_enterprise/tests/test_discuss_channel_expand.py
*/
registry
.category("web_tour.tours")
.add("mail_enterprise/static/tests/tours/discuss_channel_expand_test_tour.js", {
steps: () => [
{
trigger: ".o-mail-DiscussSystray-class [data-icon='forum']",
run: "click",
},
{
trigger: ".o-mail-MessagingMenu-tab:has(:text('Channels'))",
run: "click",
},
{
trigger: ".o-mail-NotificationItem:contains('test-mail-channel-expand-tour')",
run: "click",
},
{
trigger:
'.o-mail-ChatWindow:contains("test-mail-channel-expand-tour") [title="Open Actions Menu"]',
run: "click",
},
{
trigger: '.o-dropdown-item:contains("Open in Discuss")',
run: "click",
},
{
content:
"Check that first message of #test-mail-channel-expand-tour is shown in Discuss app",
trigger:
'.o-mail-DiscussContent .o-mail-Message-body:contains("test-message-mail-channel-expand-tour")',
},
],
});