fix(addon): replace useService('rpc') with direct rpc import for Odoo 18
rpc service was removed in Odoo 17+. Import rpc function directly from
@web/core/network/rpc instead of using useService('rpc').
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user