跳至內容
選單
此問題已被標幟
1 回覆
2294 瀏覽次數

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 ?

頭像
捨棄
最佳答案

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: {}

        })

    }

};





頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
8月 24
1194
1
5月 24
1481
2
3月 15
17352
1
3月 15
4655
0
8月 25
324