Qweb is a templating engine or reporting engine which can be used to create reports.
Odoo uses Qweb for generating reports.
Qweb provides several tools for creating a report.
By using Qweb, we can manipulate the data very easily.
• Qweb is a templating engine or reporting engine which can be used to create reports.
• Odoo uses Qweb for generating reports.
• Qweb provides several tools for creating a report.
• By using Qweb, we can manipulate the data very easily.
• Basic Features Available In Qweb For Creating A Report is discussed.
• We Use XML Attributes Prefixed By ‘T-’ For Performing The Operations.
• Just Like Any Other Programming Language, We Can Define A New Variable, Assign A
Value To It, And Use It In Our Template.
How to define a variable
t-set can be used to define a new variable and set its value.
• This will create a new variable ‘count’ and set its value to zero.
• We can set the value of the value of this variable using a function.
• Here, the value of ‘count’ will be the value returned from the function ‘my_function’.
• When we define a variable, we don’t need to specify a specific type of this variable.
• We can have several types of values such as numbers, strings, arrays(lists) and dictionaries etc.
• If we need to define a dictionary, we can achieve it like this,
• Just like this, we can use lists also.
• Iterating over the different values of a list or dictionary can be achieved by using a loop.
• In order to output a value, qweb provides t-esc and t-raw directives.
• The commonly used one is t-esc.
• t-esc will evaluate the variable and print the content of that variable
• The difference between t-esc and t-raw is, t-esc will automatically HTML-escape its
content while t-raw won’t.
• After setting a variable, we can perform our operations on that variable.
• We can use t-if to perform any conditional operations.
• The basic syntax is as follows.
• This will first check the value of ‘count’ is zero or not.
• If yes, the contents inside the t-if will be executed.
• The ‘else’ condition can be achieved by using a ‘not’ before the condition in the t-if
• The ‘not’ can be used to reverse the condition. i.e just like the else condition.
If we need to include multiple conditions, we can achieve this by using ‘and’ or ‘or’.
• In some cases, we may need to iterate over a set of values.
• Suppose we have a list or a dictionary with us and we need to iterate through
each value, in this case, we can use t-for each for this purpose.
• This will iterate over the list [1, 2, 3] and prints each element one by one.
Calling Other Templates
Calling other templates from qweb can be achieved using the t-call directive. This can
be used for top-level rendering or within a template.
• When we are handling fields, we can use t-field directive ( the result of the browser
• t-field-options can be used for customizing these fields.
• The widget is one of the most common options used with t-field options.
• We can have different types of widgets for different types of values.
Refer this link for more:
Thank You !
Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park,
Calicut University P.O.
Kerala, India - 673635.
15, ST Antonys Road,
Forest Gate, London
Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,