Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4927 Widoki

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?

Awatar
Odrzuć
Najlepsza odpowiedź

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,

Awatar
Odrzuć
Autor

Thanks a lot. It worked.

Najlepsza odpowiedź

Hi junaid,

and check 


Thanks.

Awatar
Odrzuć
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

Powiązane posty Odpowiedzi Widoki Czynność
0
lut 19
4245
1
sie 24
2148
1
lis 21
6425
2
sty 17
29189
1
lut 16
4039