初始提交

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,28 @@
import { FileViewer as WebFileViewer } from "@web/core/file_viewer/file_viewer";
import { patch } from "@web/core/utils/patch";
import { _t } from "@web/core/l10n/translation";
import { useService } from "@web/core/utils/hooks";
patch(WebFileViewer.prototype, {
setup() {
super.setup();
this.aiChatLauncher = useService("aiChatLauncher");
this.notification = useService("notification");
},
async openAIChat() {
if (this.state.file.isVideo || this.state.file.isUrlYoutube) {
this.notification.add(_t("Oops, AI cannot process videos!"), { type: "warning" });
return;
}
const fileName = this.state.file.name || 'File Attachment';
await this.aiChatLauncher.launchAIChat({
interfaceKey: "file_viewer_ai_button",
recordModel: "ir.attachment",
recordId: this.state.file.id,
channelTitle: fileName,
aiChatSourceId: this.state.file.id,
});
},
});

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="ai.AIFileViewer" t-inherit="web.FileViewer" t-inherit-mode="extension">
<xpath expr="//div[hasclass('o-FileViewer-download')]/preceding-sibling::div[hasclass('flex-grow-1')][1]" position="after">
<t t-call="ai.AIFileButton"/>
</xpath>
</t>
<t t-name="ai.AIFileButton">
<div class="o-FileViewer-headerButton d-flex align-items-center px-3 mx-1">
<button
class="cursor-pointer border-0 bg-transparent p-0"
data-hotkey="c"
t-on-click="this.openAIChat"
title="Ask AI"
>
<img src="/ai/static/description/icon.png" style="height: 22px;" alt="AI"/>
</button>
</div>
</t>
</templates>