codekarim is just a bunch of reminders for fenuapps.com
Py from openerp import models, fields class YourModel(models.Model): _name = 'your.model' def your_function(self): # CODE TO GET VALUE return value JS odoo.define('custom_webpage.my_js', function (require) {'use strict'; var Model = require('web.Model'); (new Model('your.model')).call('your_function').then(function (your_return_value) { console.log(your_return_value); }); Avatar Shameem Babu @ iWesabe 14 octobre 2016 Best Answer You can get the value through many ways First way is Py from openerp import models, fields class YourModel(models.Model): _name = 'your.model' def your_function(self): # CODE TO GET VALUE return value JS odoo.define('custom_webpage.my_js', function (require) {'use strict'; var Model = require('web.Model'); (new Model('your.model')).call('your_function').then(function (your_return_value) { console.log(your_return_value); }); }); You can watch this on YouTube How to call python function from Javascript in Odoo 10 ? How to add Js(Javascript) in Odoo 10 ? Second way Py from openerp import http class YourModel(http.Controller): @http.route(['/action_get_social_twitter'], type='json', auth="public") def get_social_twitter(self, **post): # CODE TO GET VALUE return value JS odoo.define('custom_webpage.my_js', function (require) {'use strict'; var ajax = require('web.ajax'); ajax.jsonRpc("/action_get_social_twitter", 'call').then(function(your_return_value){ console.log(your_return_value); }); }) });