콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
14857 화면

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
3548
0
4월 18
2561
0
3월 15
5639
1
9월 24
2311
2
4월 21
26290