I have created a new module in Odoo v8 and created one template in it. For that template based on some values I need to call a python method from a JS file. I have tried the following methods:
1)
function openerp_pos_models(instance){
var myModel = new instance.web.Model('my.model');
});
but on loading the page it shows instance is not defined?
2) var Users = new openerp.web.Model('res.users');
this one shows Uncaught ReferenceError: openerp is not defined and Uncaught TypeError: Cannot read property 'Model' of undefined.
How can call a method from a JS file in odoo v8? The above methods are working in v7 and v8 base modules.
me too want to know.. this.
You should make Ajax /jQuery calls from the Javascript to the Python method. Have a look at http://stackoverflow.com/questions/13175510/call-python-function-from-javascript-code this for example. Should be working in Odoo too.