Odoo Help


Simple javascript function into a page

Alessandro D'Armiento
on 8/10/15, 4:26 AM 857 views

Hello all, i would like to insert a simple button in my home page that does the following action:

If a non logged guest click the button -> display login page

If a logged customer click the button -> display shop page

To do so i edited the HTML of my page inserting the following:

Into a <div>: <button type="button" class="btn btn-success btn-lg" onlick="myFunction()">START</button>

On the top, into the main <t>:

<t name="Homepage" priority="29" t-name="website.homepage">  <---- this is the main <t> where I inserted the code


    function myFunction(){


        if <?php if ( is_user_logged_in() ) {window.location="/page/product_brands" } else {window.location="/web/login"} ?>



This not works. Please note the "alert()" as first istruction in my function to check whether or not the function itself is called, this is NEVER called.

Any help? Thank you


Vale Trood

--Vale Trood--

| 5 2 7
Tunis, France
--Vale Trood--

Vale Trood
On 8/10/15, 5:52 AM

Here are some links that may be useful for you friend:






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: 8/10/15, 4:26 AM
Seen: 857 times
Last updated: 8/10/15, 5:52 AM