Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
2285 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
0
Agu 24
1185
1
Mei 24
1477
2
Mar 15
17348
1
Mar 15
4654
0
Agu 25
294