コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
14568 ビュー

Hi,
I want to call a python function from my JavaScript code. This is my code,

rpc.query({
    model: 'my_model',
   method: 'my_method',
   args: ['']
});            

It works perfectly when I'm signed in. But the problem is, the function is not getting called when I'm not signed in. I do want to call the function from the website without signing in. Is there any solutions to achieve this ?


Thanks in advance.

アバター
破棄
最善の回答

try this instead of RPC call

this.trigger_up('button_clicked', {

name: 'my_method',
type: 'object',
record: this.record,
});
アバター
破棄
最善の回答

Hi,

For example custom model.

class custom(models.Model):

_name = "custom.model"

def get_values(self):

    return 'python method'

From the javascript file you can call like:

new Model("custom.model").call("get_values",[args]).then(function(result){

console.log(result);//show result in console

});


アバター
破棄
著作者

Thanks Sushma, but this method works only for odoo 10 and I'm dealing with odoo 11.

関連投稿 返信 ビュー 活動
1
9月 20
3261
0
4月 18
2419
0
3月 15
5374
1
9月 24
1909
2
4月 21
25926