Saturday, 31 October 2015

Odoo QWEB Reports: Tips & Trick

List of HTML elements those  are not supported directly in Qweb report. 

1) How to Use Space In Qweb Report?

   Solution - 1:

Any HTML element can be use inside CDATA[] list which is not supported directly.


   Solution - 2:


2) How to User > or < sign inside if condition?


    These conditional operators are not supported directly in Qweb or any XML file.

        A.  Instead of > symbol you have to use &gt;
        B.  Instead of < symbol you have to use &lt; 

3) How to Print & sign inside message or in any condition?

     Sol.    &amp;

4) How to use Else condition in QWeb report?

Else condition you  can use same IF Condition format, you have to add not  or ! sign before your condition starts.

 For Eg. We have partner_id fields inside our model/Object. we want to check is partner_id or not both way we will see here.

      A. <t t-if ="o.partner_id">  your code</t>

      B. <t t-if="not o.partner_id"> your code</t> 

This will work like else, likewise you can achieve else part by using this format.

 5) What is different between t-field and t-esc template inside QWeb report?

t-field: This is template defined inside odoo's standard module as XML record.
There are several templates already define inside base module for report. those are ready to use.

i) This template you can only use for the browse object/Records set which is coming from main loop.

For eg: At top we are iterating loop for-each="docs" t-as="o"

This template is useful to fetch information from the object directly.

ii) This only can be used inside HTML elements like <p> <span> <tr> etc..

t-esc: This is also the template as t-field. the behaviour of this template is  different than t-field.

i) This template used to call any function from the related parser class to fetch some runtime or dynamic information.
  A. Call Any function from parser.

  B. Define In line function or anonymous function.


ii) This template can  use inside t (Template) tag or any other HTML tag.

For eg:


Many More to come will update soon!