How to create Accounting sales Invoice Qweb report in odoo 14

 

How Create Accounting Sales Invoice in Odoo14

 

Odoo Accounting is a state-of-the-art accounting software that helps you accurately track your finances. Odoo invoicing module can be scaled as per your business requirement. By directly linking your bank accounts, you can easily track your payments, create professional invoices and manage your bills effortlessly.

 

This blog will provide insight on How to create a sale invoice qweb report in odoo 14

 

How A Accounting Sale Invoice Qweb Report Can print In Odoo?

 

1: Under report add new file named “report.xml”

Under “report.xml” add :
syntax as follws

    <report id="report_id"
          model="module.name"
          string="report related name"
          report_type="qweb-pdf"
          name="custom_module_name.body_template_id"
          file="custom_module_name.body_template_id"/>

in practical:

<report id="accounting_invoice_report_id"
      model="account.move"
      string="Accounting Report"
      report_type="qweb-pdf"
      name="odoo_training.body_template_id"
      file="odoo_training.accounting_sale_body_format"/>
-> Here name and file should be custom addon name . body template id from corresponding xml file

2: You can create an xml file inside the report directory

syntax as follows:

 

<?xml version="1.0" encoding="UTF-8" ?>

<odoo>
    <template id="report_header_template_id">
        <t t-call="web.html_container">
            <t t-if="not o" t-set="o" t-value="doc"/>
            <t t-if="not company">
                <!--  Multicompany  -->
                <t t-if="company_id">
                    <t t-set="company" t-value="company_id"/>
                </t>
                <t t-elif="o and 'company_id' in o">
                    <t t-set="company" t-value="o.company_id.sudo()"/>
                </t>
                <t t-else="else">
                    <t t-set="company" t-value="res_company"/>
                </t>
            </t>
            <div class="header" t-att-style="report_header_style">
                <div class="row">
                </div>
            </div>
            <div class="col-9 text-right" t-field="company.report_header" name="moto">
                <div t-field="company.partner_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}"/>
            </div>
            <div class="article" t-att-data-oe-model="o and o._name" t-att-data-oe-id="o and o.id" t-att-data-oe-lang="o and o.env.context.get('lang')">
                <t t-raw="0"/>
           </div>
            <div class="footer o_background_footer">
                <div>
                    <div t-field="company.report_footer"/>
                    <div t-if="report_type == 'pdf'" class="text-muted">
                        <hr style="width:100%;" color="red"/>
                        <div class="row">
                            <div class="col-6" style="text-align:right;">
                                Page:
                                <span class="page"/>
                                /
                                <span class="topage"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </t>
    </template>
<template id="report_body_template_id">
    <t t-call="web.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="module_name.report header template id">
                <div class="page">
                </div>
                </t>
            </t>
        </t>
    </template>
</odoo>

-> here you have to change header template_id, body template_id and under body template_id change this one also <t t-call=”module_name.header_template_id”>

in practical case:

 

<?xml version="1.0" encoding="UTF-8" ?>

<odoo>
    <template id="sale_order_header_format">
        <t t-call="web.html_container">
            <t t-if="not o" t-set="o" t-value="doc"/>
            <t t-if="not company">
                <!--  Multicompany  -->
                <t t-if="company_id">
                    <t t-set="company" t-value="company_id"/>
                </t>
                <t t-elif="o and 'company_id' in o">
                    <t t-set="company" t-value="o.company_id.sudo()"/>
                </t>
                <t t-else="else">
                    <t t-set="company" t-value="res_company"/>
                </t>
            </t>
            <div class="header" t-att-style="report_header_style">
                <div class="row">
                </div>
            </div>
            <div class="col-9 text-right" t-field="company.report_header" name="moto">
                <div t-field="company.partner_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}"/>
            </div>
            <div class="article" t-att-data-oe-model="o and o._name" t-att-data-oe-id="o and o.id" t-att-data-oe-lang="o and o.env.context.get('lang')">
            <t t-raw="0"/>
            </div>
            <div class="footer o_background_footer">
                <div>
                    <div t-field="company.report_footer"/>
                    <div t-if="report_type == 'pdf'" class="text-muted">
                        <hr style="width:100%;" color="red"/>
                        <div class="row">
                            <div class="col-6" style="text-align:right;">
                                Page:
                                <span class="page"/>
                                /
                                <span class="topage"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </t>
    </template>
<template id="sale_order_body_format">
        <t t-call="web.html_container">
            <t t-foreach="docs" t-as="o">
                <t t-call="odoo_training.sale_order_header_format">
                    <div class="page">
                        <div class="col-12">
                            <h5 style="text-align:left">Customer invoice</h5>
                            <h2 style="text-align:left"><t t-esc="o.name"/> </h2>
                        </div>
                    <table style="border:1px solid black;width:100%">
                        <tr>
                            <td>Customer</td>
                            <td><t t-esc="o.partner_id.name"/></td>
                            <td>Invoice Date</td>
                            <td><t t-esc="o.invoice_date"/></td>
                        </tr>
                        <tr>
                            <td> Delivery Address</td>
                            <td><t t-esc="o.partner_shipping_id.name"/> </td>
                            <td>Due Date</td>
                            <td><t t-esc="o.invoice_date_due"/> </td>
                        </tr>
                        <tr>
                            <td>Payment Reference</td>
                            <td><t t-esc="o.payment_reference"/> </td>
                            <td>Journal</td>
                            <td><t t-esc="o.journal_id.name"/> </td>
                        </tr>
                     
                    </table>
                        <table style="border:1px solid black;width:100%">
                            <tr>
                                <td style="border:1px solid black">Product</td>
                                <td style="border:1px solid black">Label</td>
                                <td style="border:1px solid black">Account</td>
                                <td style="border:1px solid black">Quantity</td>
                                <td style="border:1px solid black">UOM</td>
                                <td style="border:1px solid black">Price</td>
                                <td style="border:1px solid black">Tax</td>
                                <td style="border:1px solid black"> SubTotal</td>
                            </tr>
                            <t t-foreach="o.invoice_line_ids" t-as="one_to_many">
                                <tr>
                                 <td style="border:1px solid black"><t t-esc="one_to_many.product_id.name"/> </td>
                                 <td style="border:1px solid black"><t t-esc="one_to_many.name"/> </td>
                                 <td style="border:1px solid black"><t t-esc="one_to_many.account_id.name"/> </td>
                                 <td style="border:1px solid black"><t t-esc="one_to_many.quantity"/> </td>
                                 <td style="border:1px solid black"><t t-esc="one_to_many.product_uom_id.name"/> </td>
                                 <td style="border:1px solid black"><t t-esc="one_to_many.price_unit"/></td>
                                 <td style="border:1px solid black"><t t-esc="one_to_many.tax_ids.name"/></td>
                                 <td style="border:1px solid black"><t t-esc="one_to_many.price_subtotal"/></td>
                                 </tr>
                            </t>
                        </table>
                        <h6 style="text-align:right">Total <t t-esc="o.amount_total"/> </h6>
                        <h6 style="text-align:right">Amount Due <t t-esc="o.amount_residual"/> </h6>
                    </div>
                </t>
            </t>
        </t>
    </template>
</odoo>


* Do not forget to change header template id ;
 body template id and under body template <t t-call="module_name.header template id" in cortresponding xml file
    
                                    The print see Like This

 These twi xml files you need to add in __manifest__.py file.
To know more about us
 

 

Leave a Reply

Your email address will not be published. Required fields are marked *