diff --git a/addons/activeblue_ai/static/src/js/components/ai_panel.js b/addons/activeblue_ai/static/src/js/components/ai_panel.js index 3fd9e3d..3f67aed 100644 --- a/addons/activeblue_ai/static/src/js/components/ai_panel.js +++ b/addons/activeblue_ai/static/src/js/components/ai_panel.js @@ -1,7 +1,7 @@ /** @odoo-module **/ import { Component, useState, useRef, onMounted, onWillUnmount } from '@odoo/owl'; import { useService } from '@web/core/utils/hooks'; -import { registry } from '@web/core/registry'; +import { rpc } from '@web/core/network/rpc'; let _msgCounter = 0; function nextId() { return ++_msgCounter; } @@ -15,7 +15,6 @@ export class AiPanel extends Component { }; setup() { - this.rpc = useService('rpc'); this.notification = useService('notification'); this.messagesRef = useRef('messagesContainer'); this.inputRef = useRef('inputEl'); @@ -65,7 +64,7 @@ export class AiPanel extends Component { this._scrollToBottom(); try { - const result = await this.rpc('/ai/chat', { + const result = await rpc('/ai/chat', { message: text, context: {}, session_id: this.state.sessionId, @@ -94,7 +93,7 @@ export class AiPanel extends Component { async approve(directiveId, approved) { try { - await this.rpc('/ai/approval/respond', { + await rpc('/ai/approval/respond', { directive_id: directiveId, approved, }); @@ -112,7 +111,7 @@ export class AiPanel extends Component { _startApprovalPoll() { const poll = async () => { try { - const result = await this.rpc('/ai/approval/pending', {}); + const result = await rpc('/ai/approval/pending', {}); this.state.pendingApprovals = result.items || []; } catch { // Silently ignore poll errors diff --git a/addons/activeblue_ai/static/src/js/components/systray_button.js b/addons/activeblue_ai/static/src/js/components/systray_button.js index ca7831c..252bcef 100644 --- a/addons/activeblue_ai/static/src/js/components/systray_button.js +++ b/addons/activeblue_ai/static/src/js/components/systray_button.js @@ -1,7 +1,7 @@ /** @odoo-module **/ import { Component, useState, onMounted, onWillUnmount } from '@odoo/owl'; import { registry } from '@web/core/registry'; -import { useService } from '@web/core/utils/hooks'; +import { rpc } from '@web/core/network/rpc'; import { AiPanel } from './ai_panel'; export class SystrayButton extends Component { @@ -9,7 +9,6 @@ export class SystrayButton extends Component { static components = { AiPanel }; setup() { - this.rpc = useService('rpc'); this.state = useState({ panelOpen: false, serviceStatus: 'unknown', @@ -59,7 +58,7 @@ export class SystrayButton extends Component { this.state.serviceStatus = 'offline'; } try { - const pending = await this.rpc('/ai/approval/pending', {}); + const pending = await rpc('/ai/approval/pending', {}); this.state.pendingCount = (pending.items || []).length; } catch { this.state.pendingCount = 0;