Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
3753 Zobrazení

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?

Avatar
Zrušit
Nejlepší odpověď

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,

Avatar
Zrušit
Autor

Thanks a lot. It worked.

Nejlepší odpověď

Hi junaid,

and check 


Thanks.

Avatar
Zrušit
Autor

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

Related Posts Odpovědi Zobrazení Aktivita
0
úno 19
3880
1
srp 24
1260
1
lis 21
5648
2
led 17
28533
1
úno 16
3581