Community mailing list archives

community@mail.odoo.com

Python Function call from JS

by
yasin
- 02/27/2016 06:33:07
Hi Guys,

I have an onclick being called in qweb template, and then this onclick calls a js function which inturn calls a python function in my controller. But I am getting an error as follows when I am trying to do so.

TypeError: openerp.jsonRpc is not a function

The code in the js function is as follows:

function Print() {

var website = openerp.website;
var currentLocation = window.location;
var returnurl=openerp.jsonRpc('/print', 'call', {});
location.reload();
alert('You have signed out!');
}

And the controller function is as follows:

class print(http.Controller):

    @http.route('/print', type='json', auth="public")
    def project_signout(self):
        employee_obj = request.registry.get('hr.employee')
        employee_id = employee_obj.search(request.cr, request.session.uid, [('user_id', '=', request.session.uid)], context=request.context)
        logging.error(employee_id)
        return True

Does anyone have an idea regarding what I am doing wrong over here?


Thanks And Regards,
Yaseen Shareef

Odoo Developer/ Consultant
mayashkhan@gmail.com
Skype: yaseen.shareef91