Odoo Technical

Welcome!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

In Odoo 17 (JavaScript), the traditional rpc method used in previous versions is no longer available. Instead, only AJAX RPC can be used.

Avatar
pradicksha

In Odoo 17 (JavaScript), the traditional rpc method used in previous versions is no longer available. Instead, only AJAX RPC can be used.

Avatar
Discard
1 Answer
0
Avatar
Keerthana
Best Answer

In Odoo 17, the traditional rpc method (which was commonly used in older versions of Odoo, such as Odoo 13 or earlier) has indeed been deprecated and replaced by a more modern approach. However, it's not entirely accurate to say that only AJAX RPC can be used. Instead, Odoo 17 uses the useService hook and the rpc service provided by the OWL (Odoo Web Library) framework, which is the default frontend framework for Odoo as of version 15.

In older versions of Odoo, you could use the rpc method directly, like this:

this._rpc({

    model: 'model.name',

    method: 'method_name',

    args: [args],

}).then(function (result) {

    // Handle result

});


In Odoo 17, you should use the rpc service provided by the OWL framework. Here’s how it works:

const { useService } = owl.hooks;


class MyComponent extends owl.Component {

    setup() {

        this.rpc = useService("rpc");

    }

    async someMethod() {

        const result = await this.rpc("/web/dataset/call_kw", {

            model: 'model.name',

            method: 'method_name',

            args: [args],

            kwargs: {},

        });

        // Handle result

    }

}


Avatar
Discard