Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
4062 Vizualizări

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?

Imagine profil
Abandonează
Cel mai bun răspuns

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,

Imagine profil
Abandonează
Autor

Thanks a lot. It worked.

Cel mai bun răspuns

Hi junaid,

and check 


Thanks.

Imagine profil
Abandonează
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 Răspunsuri Vizualizări Activitate
0
feb. 19
3949
1
aug. 24
1537
1
nov. 21
5794
2
ian. 17
28695
1
feb. 16
3693