Initial commit: OCA Ai packages (4 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:05 +02:00
commit 0adb4b78b1
170 changed files with 12385 additions and 0 deletions

View file

@ -0,0 +1,32 @@
/** @odoo-module **/
import {registerPatch} from "@mail/model/model_core";
registerPatch({
name: "Chatter",
recordMethods: {
async onClickAiBridge(aiBridge) {
const saved = await this.doSaveRecord();
if (!saved) {
return;
}
const result = await this.env.services.orm.call(
"ai.bridge",
"execute_ai_bridge",
[[aiBridge.id], this.thread.model, this.thread.id]
);
if (result.action && this.env.services && this.env.services.action) {
this.env.services.action.doAction(result.action);
} else if (
result.notification &&
this.env.services &&
this.env.services.notification
) {
this.env.services.notification.add(
result.notification.body,
result.notification.args
);
}
},
},
});

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t
t-name="ai_oca_bridge.ChatterTopbar"
t-inherit="mail.ChatterTopbar"
t-inherit-mode="extension"
owl="1"
>
<xpath
expr="//div[hasclass('o_ChatterTopbar_rightSection')]/button[1]"
position="before"
>
<ChatterAITopbar
record="chatterTopbar"
t-if="chatterTopbar.chatter.webRecord.data.ai_bridge_info !== undefined and chatterTopbar.chatter.webRecord.data.ai_bridge_info.length > 0"
/>
</xpath>
</t>
</templates>

View file

@ -0,0 +1,24 @@
/** @odoo-module **/
import {ChatterAIItem} from "../chatter_topbar_ai_item/chatter_topbar_ai_item.esm";
const {Component} = owl;
import {Dropdown} from "@web/core/dropdown/dropdown";
import {DropdownItem} from "@web/core/dropdown/dropdown_item";
import {registerMessagingComponent} from "@mail/utils/messaging_component";
export class ChatterAITopbar extends Component {
/**
* @returns {ChatterAITopbar}
*/
get chatterTopbar() {
return this.props.record;
}
}
Object.assign(ChatterAITopbar, {
props: {record: Object},
components: {Dropdown, DropdownItem, ChatterAIItem},
template: "ai_oca_bridge.ChatterAITopbar",
});
registerMessagingComponent(ChatterAITopbar);

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="ai_oca_bridge.ChatterAITopbar" owl="1">
<Dropdown
class="'btn-group o_ChatterTopbar_AIButton'"
togglerClass="'btn btn-secondary ai_button_selection text-uppercase'"
hotkey="'i'"
showCaret="true"
>
<t t-set-slot="toggler">
<i class="fa fa-bolt" />
</t>
<t
t-foreach="props.record.chatter.webRecord.data.ai_bridge_info"
t-as="aiBridge"
t-key="aiBridge.id"
>
<DropdownItem
class="'dropdown-item'"
onSelected="() => this.props.record.chatter.onClickAiBridge(aiBridge)"
>
<ChatterAIItem bridge="aiBridge" />
</DropdownItem>
</t>
</Dropdown>
</t>
</templates>

View file

@ -0,0 +1,46 @@
/** @odoo-module **/
const {Component, markup} = owl;
import {usePopover} from "@web/core/popover/popover_hook";
export class ChatterAIItemPopover extends Component {}
ChatterAIItemPopover.template = "ai_oca_bridge.ChatterAIItemPopover";
export class ChatterAIItem extends Component {
setup() {
super.setup();
this.popover = usePopover();
this.tooltipPopover = null;
}
get tooltipInfo() {
return {
help: markup(this.props.bridge.description || ""),
};
}
onMouseEnter(ev) {
this.closeTooltip();
this.tooltipPopover = this.popover.add(
ev.currentTarget,
ChatterAIItemPopover,
this.tooltipInfo,
{
closeOnClickAway: true,
position: "top",
}
);
}
onMouseLeave() {
this.closeTooltip();
}
closeTooltip() {
if (this.tooltipPopover) {
this.tooltipPopover();
this.tooltipPopover = null;
}
}
}
ChatterAIItem.template = "ai_oca_bridge.ChatterAIItem";
ChatterAIItem.props = {bridge: Object};

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="ai_oca_bridge.ChatterAIItem" owl="1">
<span class="o_ChatterTopbar_AIItem">
<t t-esc="props.bridge.name" />
<i
class="fa fa-info-circle ms-1"
role="img"
t-on-mouseenter="(ev) => this.onMouseEnter(ev)"
t-on-mouseleave="(ev) => this.onMouseLeave(ev)"
t-if="props.bridge.description"
/>
</span>
</t>
<t t-name="ai_oca_bridge.ChatterAIItemPopover" owl="1">
<div class="popup-div">
<p class="popover-content p-2">
<t t-out="props.help or ''" />
</p>
</div>
</t>
</templates>