Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4919 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.พ. 19
4244
1
ส.ค. 24
2143
1
พ.ย. 21
6416
2
ม.ค. 17
29184
1
ก.พ. 16
4039