Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
4599 Visualizações

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
Cancelar
Melhor resposta

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
Cancelar
Autor

Thanks a lot. It worked.

Melhor resposta

Hi junaid,

and check 


Thanks.

Avatar
Cancelar
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

Publicações relacionadas Respostas Visualizações Atividade
0
fev. 19
4111
1
ago. 24
1906
1
nov. 21
6098
2
jan. 17
28987
1
fev. 16
3842