تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
4958 أدوات العرض

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
فبراير 19
4273
1
أغسطس 24
2200
1
نوفمبر 21
6467
2
يناير 17
29217
1
فبراير 16
4056