Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
2249 Weergaven

I want to use web.rpc on my JS to manipulate display on pivot table, but it get error like unmet dependencies. I use like this 

var rpc = require('web.rpc');

but that get error on odoo 17, and I want to use that for rpc.query. Any alternative or solution with that approach ?

Avatar
Annuleer
Beste antwoord

You can used to import the useService hook from the @web/core/utils/hooks package in Odoo's JavaScript framework.


// Example 


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


export const MyComponent = () => {

    setup() {

        super.setup();

        this.rpc = useService("rpc");

    }


    async onClickRPC() {

        await this.rpc("URL", {

            model: 'res.users',

            method: 'method_name',

            args: [],

            kwargs: {}

        })

    }

};





Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
aug. 24
1159
1
mei 24
1453
2
mrt. 15
17335
1
mrt. 15
4635
2
jul. 25
1473