Odoo Help


Website - Add onchange function that call Python function

Evans Bernier
on 6/12/16, 12:43 PM 2,086 views


I creating a Website module. I have a form created using  a template. All is working well. I dont have any javascript file for now. I would like to add a field, that call a python function when the value change. The python function will give back a result that I would like to display on the same form.

I saw many example that use a javascript Widget the get it work, but no example for frontend (website).

I try to add a simple Javascript file to test if my Javascript is loaded, but not working.

This is my code.


<template id="assets_frontend_test" inherit_id="website.assets_frontend" name="Assets Frontend test">
    <xpath expr="." position="inside">
        <script type="text/javascript" src='/test_module/static/src/js/test.js'></script>    

<template id="test">
    <t t-call="website.layout">
     <t t-set="title">TEST</t>
        <div class="oe_structure">
         <div class="container">


(function () {
    'use strict';
    var _t = openerp._t;
    var website = openerp.website;
    website.Test = openerp.Widget.extend({
        template: 'test_module.test',
        start: function() {
            console.log("TEST WIDGET!!!");

    website.ready().done(function() {
console.log("test READY!!!!");
var test = new website.Test();


How can I do it work? I am not sure of what I do with template on JS file. On frontend, we use QWeb to display a template...

Can you help me to make this example work?  After, I know that I have to add "event" to call onchange function that call XMLRPC.


Evans Bernier
On 6/13/16, 9:30 AM

I forgot to paste my controller:


@http.route('/page/test/', type='http', auth='user', website=True)
def test(self, **kw):
    return request.render('test_module.test', {})

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/12/16, 12:43 PM
Seen: 2086 times
Last updated: 6/13/16, 9:30 AM