Odoo Help


How to execute javascript inside qweb template

Shawn Varghese
on 1/26/15, 3:54 AM 3,955 views

How do I execute javascript in qweb? I read through the documentation and it mentioned a t-js tag. But I can't get it to work.

I have created a table in a qweb report. But if the table cannot fully fit onto one page, I need to insert a page-break before the table. Therefore, it becomes a conditional page-break. For this I need to obtain the height of the table. One technique is through javascript:

var table = document.getElementById("tableId");


I need to execute these lines in QWeb, and then I also need to pass the value of the offset height  from javascript to a qweb variable. Is this possible?

I find QWeb to be a powerful tool for dynamic HTML generation, but sadly, the documentation is very poor.

I would also love to know how to accomplish this. I believe javascript can be the answer to my question posted here: https://www.odoo.com/forum/help-1/question/qweb-drop-trailing-0s-after-decimal-73314

Cliff Kujala
on 1/27/15, 9:35 AM

I've just bumped into the same issue. Per the documentation, it is clear that placing "t-js" node inside the template does exactly what you require (https://www.odoo.com/documentation/8.0/reference/qweb.html). However, as I try it, it just 'prints' the javascript code into the pdf report (¿?), as if it were any regular html tag. Have any of you had any luck with this matter?

Poiesis Consulting SRL, Nico Bustillos
on 2/4/16, 4:17 PM
Yudy Tirana
On 5/19/17, 5:50 AM

I am also trying to find a solution for this, can anyone help ?

On 5/28/16, 8:32 AM

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

4 follower(s)


Asked: 1/26/15, 3:54 AM
Seen: 3955 times
Last updated: 7/11/17, 11:54 PM