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

odoo.define('module.custom_name', [] ,function (require) {

"use strict";
const rpc = require('web.rpc');
var ajax = require('web.ajax');

$(document).ready(function () {

$('#custom_btn').on('click', function (event) {

ajax.jsonRpc("/controller", 'call', {
 --------
}).then(function(data) {
 -------------
});
this structure is not working. How to do controller call in odoo 17?

頭像
捨棄
最佳答案

Hi,First import jsonrpc from rpc_service: and try following,to add custom logic inside the then function,
/** @odoo-module **/

import { jsonrpc } from "@web/core/network/rpc_service";

$(document).ready(function () {

$('#custom_btn').on('click', function (event) {await jsonrpc('/controller', {}).then( function(data){
         ---------
            })
    }

If we have any context data, const token = await jsonrpc('/totphook', {
            secret: $secret.text()
        });

Hope it helps,

頭像
捨棄
作者

Thanks a lot. It worked.

最佳答案

Hi junaid,

and check 


Thanks.

頭像
捨棄
作者

Thanks a lot. It worked.
In the other solution "jsonrpc" seems to give much faster response. But Thanks again. Badly needed a solution.

yes junaid

相關帖文 回覆 瀏覽次數 活動
0
2月 19
4248
1
8月 24
2151
1
11月 21
6432
2
1月 17
29192
1
2月 16
4041