javascriptodooodoo-owl

Odoo OWL error Service rpc is not available


I'm trying to use the Odoo OWL libraries and I'm following what is explained in the documentation.

import { Component } from "@odoo/owl";
import { useService } from "@web/core/utils/hooks";

export class ReviewUnderName extends Component {

    static template = "devolive_review.ReviewUnderName";
    static props = {};

    setup() {
        this.rpc = useService("rpc");
        this.loadData();
    }

    async loadData() {
        const response = await this.rpc(`/devolive/review/`);
        console.log("response", response);
    }

Unfortunately, I'm getting the error: Service rpc is not available
Does anyone know if there is extra steps to be able to use the rpc service with Odoo OWL Components?

Odoo OWL error  Service rpc is not available


Solution

  • In Odoo 18 source code i couldn't find any usage of useService("rpc").

    The documentation is not always up-to-date (especially regarding JS stuff), so it might be an outdated feature (Odoo 15, 16, 17) ...

    Instead i found this in Odoo 18:

    import { rpc } from "@web/core/network/rpc";
    

    As you can see here from Tests seems to be the new way of use the rpc:

    Odoo 17 source code Web module

    Odoo 18 Source Code Web module