Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create PDF report for account module in Odoo-9?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.16k
    Comment on it

    In Odoo-9 first we install the accounting module and then create new module and inherits the account.invoice object in account module to own your module and give type is pdf in module.

    Follow these step show below:

    Step1:- First we create new module for i.e student and create all file show below

    1- __init__.py file

    2- __openerp__.py file

    3- student.py file

    4- student.xml file

    In __init__.py file using this code

    import student

     

    Step2:- Then inherits the account.invoice object from your account module and validate it in student.py file. Use this code show below

    from openerp import api, models
    class account_invoice(models.AbstractModel):
        _inherit='account.invoice'
        _description = 'account_invoice'
        _columns = {                              
                    }   
    account_invoice() 

     

    Step3:- Then create the XML file student.xml and inherit the account.invoice model in your account module . Use this code show below

    <?xml version="1.0" encoding="utf-8"?>
    <openerp>
        <data>
    		<report 
                id="action_report_student_attendance"
                model="account.invoice"
                string="RENT INVOICE"
                report_type="qweb-pdf"
                file="Student.report_studentattendancelist"
                name="Student.report_studentattendancelist"/>            
            <report 
                id="action_report_student_attendance2"
                model="account.invoice"
                string="CUSTOM REPORT INVOICE"
                report_type="qweb-pdf"
                file="Student.report_studentattendancelist2"
                name="Student.report_studentattendancelist2"/>        
           </data>
    </openerp>

     

    Step4:- Then create view regarding your report and design report as par requirement. Use this code show below

    <?xml version="1.0" encoding="utf-8"?>
    <openerp>
    <data>
    <template id="report_studentattendancelist">
        <t t-call="report.html_container">
            <t t-foreach="docs" t-as="o">
                <t t-call="report.internal_layout">
                    <div class="page">
                       <div class="oe_structure"/>
                       <div class="row">
                         <tbody>
                         <!-- 
                         <div style="width: 100%; text-align: center;">
    		                   <img src="web/static/src/img/goldenmusic.jpg" alt="Golden Music Center" width="200" height="150"/>		                </div>
                          -->
                          </tbody>		               
    		                <div style="float:left; width: 40%">
    		                   <h2>Rent-To-Own Invoice</h2>
    		                </div>
    		                <div style="clear: both;"></div>
    		                
    		                <div style="clear: both;"></div>
    		                <div style="width: 100%;">
    		                   <table style="width: 100%; text-align: center;" border="0">
    		                      <thead>
    		                          <tr><td style="border:1px solid black">Invoice Date</td><td  style="border:1px solid black;">Due Date</td><td style="border:1px solid black;">Reference</td></tr>
    		                      </thead>
    		                      <tbody>
    		                          <tr><td style="border:1px solid black;"><p t-field="o.date_invoice"/></td><td style="border:1px solid black;"><p t-field="o.date_due"/></td><td style="border:1px solid black;"><p t-field="o.number"/></td></tr>
    		                      </tbody>
    		                    </table>
    		                   <p style="border:1px solid black; padding: 6px; margin-top:10px;"><strong>HELLO</strong>,<br/>Please fill your detail</p>
    		                </div>
    		                
    		                  <div style="clear: both;"></div>
    
    				            <div style="float:left; width: 50%; text-align: left; font-weight: bold"> 
    				                      <address t-field="o.partner_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}"/>
    				                    <span t-if="o.partner_id.vat">TIN: <span t-field="o.partner_id.vat"/></span>                 
    				          </div>
    				          
    						          <div style="float:left; width: 50%">
    		                   <h4>
    		                      <span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Invoice</span>
    		                       <span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA</span>
    		                       <span t-if="o.type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span>
    		                       <span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span>
    		                      <span t-if="o.type == 'out_refund'">Refund</span>
    		                      <span t-if="o.type == 'in_refund'">Vendor Refund</span>
    		                     <span t-if="o.type == 'in_invoice'">Vendor Bill</span>
    		                     <span t-field="o.number"/>
    		                  </h4>
    		                </div>
    		                
    		                <div class="row mt32 mb32">
    			                <div class="col-xs-2" t-if="o.name">
    			                    <strong>Description:</strong>
    			                    <p t-field="o.name"/>
    			                </div>
    			            
    			                <div class="col-xs-2" t-if="o.origin">
    			                    <strong>Source:</strong>
    			                    <p t-field="o.origin"/>
    			                </div>
    			                <div class="col-xs-2" t-if="o.partner_id.ref">
    			                    <strong>Customer Code:</strong>
    			                    <p t-field="o.partner_id.ref"/>
    			                </div>
    			                <div name="reference" class="col-xs-2" t-if="o.reference">
    			                    <strong>Reference:</strong>
    			                    <p t-field="o.reference"/>
    			                </div>
                			</div>
                			
                			 <!-- Is there a discount on at least one line? -->
                <t t-set="display_discount" t-value="any([l.discount for l in o.invoice_line_ids])"/>
    
                <table class="table table-condensed">
                    <thead>
                        <tr>
                            <th>Description</th>                  
                            <th class="text-right">Quantity</th> 
                                         
                            <th class="text-right">Unit Price</th>
                            <th t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">Disc.(%)</th>
                            <th class="text-right">Taxes</th>
                            <th class="text-right">Price</th>
                        </tr>
                    </thead>
                    <tbody class="invoice_tbody">
                        <tr t-foreach="o.invoice_line_ids" t-as="l">
                            <td><span t-field="l.name"/></td>
                               <td  class="text-right"> <span t-field="l.quantity"/> </td>
                            <td class="text-right">                                                 
                         
                                <span t-field="l.uom_id" groups="product.group_uom"/>
                            </td>
                            <td class="text-right">
                                <span t-field="l.price_unit"/>
                            </td>
                            <td t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">
                                <span t-field="l.discount"/>
                            </td>
                            <td class="text-right">
                                <span t-esc="', '.join(map(lambda x: (x.description or x.name), l.invoice_line_tax_ids))"/>
                            </td>
                            <td class="text-right">
                                <span t-field="l.price_subtotal" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>
                            </td>
                        </tr>
                    </tbody>
                 </table>    
                      <div class="row">
                    <div class="col-xs-4 pull-right">
                        <table class="table table-condensed">
                            <tr class="border-black">
                                <td><strong>Subtotal</strong></td>
                                <td class="text-right">
                                    <span t-field="o.amount_untaxed" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>
                                </td>
                            </tr>
                            <t t-foreach="o._get_tax_amount_by_group()" t-as="amount_by_group">
                                <tr>
                                    <td><span t-esc="amount_by_group[0]"/></td>
                                    <td class="text-right">
                                        <span t-esc="amount_by_group[1]"/>
                                    </td>
                                </tr>
                            </t>
                            <tr class="border-black">
                                <td><strong>Total</strong></td>
                                <td class="text-right">
                                     <span t-field="o.amount_total" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
       		            <p t-if="o.comment">
    			                <strong>Comment:</strong>
    			                <span t-field="o.comment"/>
    			            </p>
    			            <p t-if="o.payment_term_id">
    			                <span t-field="o.payment_term_id.note"/>
    			            </p>
    			            <p t-if="o.fiscal_position_id.note">
    			                <strong>Fiscal Position Remark:</strong>
    			                <span t-field="o.fiscal_position_id.note"/>
    			            </p>
    			            <p><strong>Change of Address? </strong><br/> Please note . self here: __________________________________</p>
                                 
                       </div>
                     </div>
                    </t>
                </t>
            </t>
        </template>
    </data>
    </openerp>
    

     

    I have attached full module, you can download the ZIP file for further use.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: