Wednesday, 2 December 2015

Odoo Reporting Basic

Here am explaining some tags in odoo reporting.
It will help you at the time of report customization.

Adding an Image



  <div class="col-xs-2">
<img t-if="o.company_id.logo" t-att- src="'data:image/png;base64,%s' %                                      o.company_id.logo" style="max-height: 150px;"/>
  </div>
 

                                or

  <img src="http://theoffice-int.com/wp-content/uploads/2015/06/THE-OFFICE-logo-180-x-99.png"     alt="The Offices" style="width:200px; height:100px"/>



Adding Header



  <div class="header">
    <t t-foreach="o.company_id.header_image" t-as="images">
<t t-if="images.name == 'header_logo'">
          <div class="oe_structure"/>
         <img t-if="images.img" t-att-src="'data:image/png;base64,%s' % images.img" style="max-                   height: 200px;"/>
</t>
   </t>
  </div>



Adding Footer


 <div class=“footer">
 <t t-foreach="o.company_id.footer_image" t-as="images">
<t t-if="images.name == ‘footer_logo'">
<div class="oe_structure"/>
<img t-if="images.img" t-att-src="'data:image/png;base64,%s' % images.img" style="max-                  height: 200px;"/>
</t>
</t>
</div>

Setting ‘company’


<t t-if="o and 'company_id' in o">
<t t-set="company" t-value="o.company_id"/>
</t>
<t t-if="not o or not 'company_id' in o">
<t t-set="company" t-value="res_company“/>
</t>


Adding Page Number


<div class=“footer">
<center>
Page<span class=“page”/>
/
<span class=“topage”/>
</center>
</div>

Format Date



<p t-field="o.date_order" t-field-options='{"format": "dd/ MM/ yyyy"}'/>

Current Date


<span t-esc="time.strftime('%d-%m-%Y ')"/>

OR

<span t-esc="formatLang(time.strftime('%Y-%m-%d'), date=True)"/>


Offsetting


<div style="padding-top: 80px; padding-left: 70px;">
<div class="col-xs-12">
<div class="col-xs-6"><h4><b> <span t-field="o.od_unit_ids.municipality_num" /></b></h4></div>
<div class="col-xs-offset-9"><h4><b><span t-field="o.date" t-field-options='{"format": "dd/ MM/ yyyy"}' /></b></h4></div>
</div>
</div>

Setting Font

<p style="font: Comic Sans, Comic Sans MS, cursive; font-size: 16px; color: silver;">
<t t-esc="o.partner_id.name"/>
 </p>


Setting Background


<div style="background-image: url('http://theoffice-int.com/wp-content/uploads/2015/06/123.png'); background-size: 860px 580px; background-repeat: no-repeat; width: 870px; height: 576px;">
<div style="width: 820px; padding-top: 310px; text-align: center">
<strong>

</strong>    
</div>
</div>


Table


<table class="table table-condensed" style="border: 1px solid black; width:100%">
                <thead style="background-color:#E6E6FA">
                    <tr>
                        <th style="border-left:1px solid black;width:30%">Description</th>
<th></th>
                     
                    </tr>
               </thead>
<t t-set="count" t-value="0"/>
               <tbody >
                    <t t-foreach="o.order_line" t-as="l">
<t t-set="count" t-value="count+1"/>
                        <tr>
<td style="border-left:1px solid black;width:35%">
                            <span t-field=“count"/>
                        </td>
<td style="border-left:1px solid black;width:35%">
                            <span t-field="l.name"/>
                        </td>
</tr>
               </tbody>
</table