Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3919 Lượt xem


in model "test.study", i defined a function:


def justtest(self):


​print("hello owl")




and in web frontend, i have a js file, defined a component, in this component, i defined another function ,want to remotely call python function "justtest":


setup(){


this.rpc = useService("rpc");


}


async clicktest(){


​await ​this.rpc(


​ ​model: "test.study",


​ ​method: "justtest",


        );


}




when I click the button on the web page, trigger the js function "clicktest", system warn errors, and shows in the log:   "POST /[object%20object] HTTP/1.1" 404,




what's the right way to call python function ?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Please make use of RPC to execute python functions from js. You can pass arguments too from js to python using rpc. 


Please refer to this article to understand more about rpc: https://www.cybrosys.com/odoo/odoo-books/odoo-16-development/web-development/rpc-calls/


Hope it helps

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi GrantS,

You can use following ways using RPC call using call python method on particulate model.

Thanks.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 25
2088
1
thg 4 25
3170
1
thg 4 25
3941
1
thg 4 25
1487
4
thg 3 25
6452