Is there any way to call a javascript function from python or any workaround to achieve a similar result?
I basically want to call a certain javascript function when a scheduler runs.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Is there any way to call a javascript function from python or any workaround to achieve a similar result?
I basically want to call a certain javascript function when a scheduler runs.
you have to use the RPC:
https://doc.odoo.com/trunk/web/rpc/
Use 'this', single quotes and the done function and it should work:
this._model = ...;
var x = this._model.call('my_method',[]).done(function(results){
whatever;
});
You can use get_func from JS to call py function :
new instance.web.Model("<model>").get_func("<py function>")(<args>)
This is a sample code from module.PosWidget (point_of_sales/static/src/js/widget.js) :
new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_session_opening']], ['res_id'])
Thanks Vasanth, but could you please explain a little more:
A scheduler calls a python function "my_function"
"my_function" is defined similar to:
def my_function(self,cr,uid,ids,context=None):
call some javascript function()
return True
Is this possible?
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Jun 25
|
3588 | ||
|
1
Sep 19
|
10517 | ||
|
3
Dec 23
|
45604 | ||
|
0
Mar 15
|
3526 | ||
|
0
Mar 15
|
3694 |