Odoo Help

Welcome!

This community 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.

2

How to execute javascript inside qweb template

By
Shawn Varghese
on 1/26/15, 3:54 AM 2,213 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");

alert(table.offsetHeight);

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
0
Adel
On 5/28/16, 8:32 AM


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 1/26/15, 3:54 AM
Seen: 2213 times
Last updated: 6/13/16, 4:41 AM