Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
10383 Näkymät

Hi, I would like to know when we create a custom report is it possible to create a block (div) that can be repeated on all pages of the report without it being in the header or in the footer?

If yes; how to do it ?

I work on odoo 11 Enterprise version

Avatar
Hylkää

Hello Ben,
Did you find a way to repeat the div.

Tekijä Paras vastaus

In red my header and in blue the content of the page so my header overlaps with the content of the page and even I try to change the height of the header it does not work.

Here is my code, if it can help

<odoo>

<report
    id="account_invoices"
    model="sale.order"
    string="Pro-forma"
    report_type="qweb-pdf"
    name="sale_discount.report_saleorder_pro_forma_t"
    file="sale_discount.report_saleorder_pro_forma_t"
    attachment_use="True"
    attachment="(object.state in ('open','paid')) and
        ('INV'+(object.number or '').replace('/','')+'.pdf')"
/>


<template id="report_invoicess">
    <t t-call="web.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="sale_discount.internal_layout_test">
                <div class="header" style="border:1px solid #1d0296;">
                    <div bottom="100px;">
                        <div class="col-xs-12" style="border:1px solid #cccccc;">
                            <div class="col-xs-6"  style="padding:20px">
                            <h2>
                                <t t-if="not (env.context.get('proforma', False) or is_pro_forma)">
                                    <span t-if="doc.state not in ['draft','sent']">Order # </span>
                                    <span t-if="doc.state in ['draft','sent']">Quotation # </span>
                                </t>
                                <t t-if="env.context.get('proforma', False) or is_pro_forma">
                                    <span>Proforma N°.- </span>
                                </t>
                                <span t-field="doc.name"/>
                            </h2>
                            </div>
                            <div class="col-xs-5 col-xs-offset-1"  style="padding:20px">
                                <p><strong>Détails du client</strong></p>
                                <div t-field="doc.partner_id"
                                    t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
                                <p t-if="doc.partner_id.vat"><t t-esc="doc.company_id.country_id.vat_label or 'TIN'"/>: <span t-field="doc.partner_id.vat"/></p>
                            </div>
                        </div>

                        <div class="col-xs-12" style="border:1px solid #000000; padding:20px">
                            <div t-if="doc.client_order_ref" class="col-xs-3">
                                <strong>Reference Client:</strong>
                                <p t-field="doc.client_order_ref"/>
                            </div>
                            <div t-if="doc.confirmation_date and doc.state not in ['draft','sent']" class="col-xs-3">
                                <strong>Date de Confirmation:</strong>
                                <p t-field="doc.confirmation_date" t-field-options='{"format": "d/M/y"}'/>
                            </div>
                            <div t-if="doc.date_order and doc.state in ['draft','sent']" class="col-xs-3">
                                <strong>Date de la Proforma:</strong>
                                <p t-field="doc.date_order" t-field-options='{"format": "d/M/y"}'/>
                            </div>
                            <div t-if="doc.user_id.name" class="col-xs-3">
                                <strong>Vendeur:</strong>
                                <p t-field="doc.user_id"/>
                            </div>
                            <div t-if="doc.user_id.name" class="col-xs-3">
                                <strong>Contact N°:</strong>
                                <p t-field="doc.user_id.phone"/>
                            </div>
                            <div t-if="doc.user_id.name" class="col-xs-3">
                                <strong>Email:</strong>
                                <p t-field="doc.user_id.login"/>
                            </div>
                        </div>
                        <div class="col-xs-12" style="border:1px solid #000000; height:25px;">
                    </div>
                </div>
                </div>
                
                 <div class="page" >
            <!--div class="oe_structure"/-->
        
            <!-- Is there a discount on at least one line? -->
            <t t-set="display_discount" t-value="any([l.discount for l in doc.order_line])"/>


            <t t-foreach="doc.order_lines_layouted()" t-as="page">
                <!--table class="table table-condensed" style="border:1px solid #cccccc;" border="1"-->
                <div width="100%"  heigth="auto" style="border:0px solid #000000;">
                <table class="table table-condensed" >
                    <thead >
                        <tr>
                            <th class="text-center" style="border-right:1px solid #000000">Description</th>
                            <th class="text-center" style="border-right:1px solid #000000">Quantité</th>
                            <th class="text-center" style="border-right:1px solid #000000">Prix Unitaire</th>
                            <th t-if="display_discount" class="text-center" groups="sale.group_discount_per_so_line" style="border-right:1px solid #000000">REMISE.(%)</th>
                            <th class="text-center" style="border-right:1px solid #000000">T.V.A</th>
                            <th class="text-center" groups="sale.group_show_price_subtotal">COUT H.T.</th>
                            <!--th class="text-center">COUT T.T.C</th-->
                        </tr>
                   </thead>
                   <tbody class="sale_tbody">
                        <t t-foreach="page" t-as="layout_category">

                            <t t-if="layout_category_size > 1 or page_size > 1" groups="sale.group_sale_layout">
                                <tr class="active">
                                    <td colspan="7" style="font-weight: bold; border-bottom: 0px solid black;">&amp;bull;
                                        <t t-esc="layout_category['name']"/>
                                    </td>
                                </tr>
                            </t>

                            <!--t t-set="i" t-value="1"/>
                                <tr t-foreach="o.order_line" t-as="l">
                                     <Check Condition and break>
                                    <td> <span t-esc="i"/></td>
                                    <t t-set="i" t-value="i+1"/>
                                </tr>
                            </t-->

                            <!-- Lines associated -->
                            <t t-foreach="layout_category['lines']" t-as="l">
                                <tr>
                                    <td><span t-field="l.name"/></td>
                                    <td class="text-right">
                                        <span t-field="l.product_uom_qty"/>
                                        <span t-field="l.product_uom" 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.tax_id))"/>
                                    </td>
                                    <td class="text-right" groups="sale.group_show_price_subtotal" style="background-color: transparent !important;">
                                        <span t-field="l.price_subtotal"
                                            t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
                                    </td>
                                    <!--td class="text-right" style="background-color: transparent !important;">
                                        <span t-field="l.price_total"
                                            t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
                                    </td-->
                                </tr>
                            </t>
                            <!--t t-if="page_index &lt; page_size - 1" groups="sale.group_sale_layout">
                    <p style="page-break-before:always;"> </p>
                            </t-->

                            <t t-if="(layout_category_size > 1 or page_size > 1) and layout_category['subtotal']" groups="sale.group_sale_layout">
                                <tr class="text-right">
                                    <td colspan="6">
                                        <strong>Subtotal: </strong>
                                        <t t-set="subtotal" t-value="sum(line.price_subtotal for line in layout_category['lines'])"/>
                                        <span t-esc="subtotal" t-options="{'widget': 'monetary', 'display_currency': doc.pricelist_id.currency_id}"/>
                                    </td>
                                </tr>
                            </t>

                        </t>
                    </tbody>
                </table>

                <table width="100%" style="border-color:#ffffff !important">
                    <tr>
                        <td style="border-color:#ffffff; border-left-color:#ffffff;" width="65%">
                            <p style="padding:5px"><strong>Montant en lettres : </strong><span t-field="doc.montant_lettre"/></p>
                        </td>
                        <td style="background-color: transparent !important;border-color:#ffffff;" width="35%">
                            <table class="table table-condensed" style="min-width:200px;max-width: 350px;" border="">
                                    <tr class="border-black"  t-if="display_discount"  style="border:1px solid #000000">
                                        <td><strong>Montant sans Remise</strong></td>
                                        <td class="text-right"  style="background-color: transparent !important;">
                                            <span t-field="doc.amount_undiscount"
                                                t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
                                        </td>
                                    </tr>
                                    <tr class="border-black"  t-if="display_discount"  style="border:1px solid #000000;">
                                        <td><strong>Remise</strong></td>
                                        <td class="text-right"  style="background-color: transparent !important;">
                                        <span t-field="doc.total_discount"
                                                    t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
                                        </td>
                                    </tr>
                                    <tr class="border-black"  style="border:1px solid #000000">
                                        <td><strong>Total H.T.</strong></td>
                                        <td class="text-right"  style="background-color: transparent !important;">
                                           <span t-field="doc.amount_untaxed"
                                                 t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
                                        </td>
                                    </tr>
                                    <t t-foreach="doc._get_tax_amount_by_group()" t-as="amount_by_group">
                                        <tr style="border:1px solid #000000;">
                                            <t t-if="amount_by_group[3] == 1 and doc.amount_untaxed == amount_by_group[2]">
                                                <td>
                                                    <span t-esc="amount_by_group[0]"/>
                                                    <span>&amp;nbsp;<span>on</span>&amp;nbsp;<t t-esc="amount_by_group[2]" t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/></span>
                                                    </td>
                                                    <td class="text-right" style="background-color: transparent !important;">
                                                        <span t-esc="amount_by_group[1]"
                                                            t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
                                                    </td>
                                                </t>
                                                <t t-else ="">
                                                <td>
                                                    <span t-esc="amount_by_group[0]"/>
                                                </td>
                                                <td class="text-right" style="background-color: transparent !important;">
                                                    <span t-esc="amount_by_group[1]"
                                                        t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
                                                </td>
                                            </t>
                                       </tr>
                                    </t>
                                    <tr class="border-black"  style="border:1px solid #000000;">
                                        <td><strong>Total</strong></td>
                                        <td class="text-right"  style="background-color: transparent !important;">
                                            <span t-field="doc.amount_total"
                                                t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
                                        </td>
                                    </tr> 

                                    <tr class="border-black"  t-if="(doc.currency_id.name == 'CDF')" style="border:1px solid #000000;">
                                        <td style="border-color:#ffffff;background-color: transparent !important;"></td>
                                    </tr> 

                                    <tr class="border-black"  t-if="(doc.currency_id.name == 'CDF')" style="border:1px solid #000000;">
                                        <td><strong>Taux</strong></td>
                                        <td class="text-right"  style="background-color: transparent !important;">
                                            <span t-field="doc.currency_id.rate"
                                                t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
                                        </td>
                                    </tr> 
                                    <tr class="border-black"  t-if="(doc.currency_id.name == 'CDF')" style="border:1px solid #000000;">
                                        <td><strong>Total USD</strong></td>
                                        <td class="text-right"  style="background-color: transparent !important;">
                                            <t t-set="subtotalusd" t-value="(doc.amount_total / doc.currency_id.rate)"/>
                                            <span t-esc="subtotalusd" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
                                            <!--span t-field="doc.currency_id.round(amount_total)"
                                                t-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/-->
                                        </td>
                                    </tr> 
                                </table>
                            </td>   
                        </tr>
                        <tr>
                            <td height="10px;" style="border-color:#ffffff;background-color: transparent !important;"></td>
                        </tr>
                    </table>
                    </div>

                <div class="col-xs-12" style="margin-top:10%;">
                    <table style="border-color:#ffffff !important">
                        <tr>
                            <td width="65%" style="border-color:#ffffff;">
                                <table class="table table-condensed" style="min-width: 200px;max-width: 350px;">
                                    <tr class="border-black" style="border:1px solid #000000;">
                                        <td><strong>Prix Rendu:</strong></td>
                                        <td class="text-right" style="background-color: transparent !important;">
                                            <span t-field="doc.prix_rendu"/>
                                        </td>
                                    </tr>
                                    <tr class="border-black" style="border:1px solid #000000;">
                                        <td><strong>Modalité de paiement :</strong></td>
                                        <td class="text-right" style="background-color: transparent !important;">
                                            <span t-field="doc.mode_paiement"/>
                                        </td>
                                    </tr>
                                    <tr class="border-black" style="border:1px solid #000000;">
                                        <td><strong>Validité :</strong></td>
                                        <td class="text-right" style="background-color: transparent !important;">
                                            <span t-field="doc.valide_livraison"/>
                                        </td>
                                    </tr>
                                    <tr class="border-black" style="border:1px solid #000000;">
                                        <td><strong>Livraison :</strong></td>
                                        <td class="text-right" style="background-color: transparent !important;">
                                            <span t-field="doc.livraison"/>
                                        </td>
                                    </tr>
                                    <tr class="border-black" style="border:1px solid #000000;">
                                        <td><strong>Termes et Conditions : -  </strong></td>
                                        <td style="background-color: transparent !important;">
                                            <span><strong>1:- En cas d'exoneration à la T.V.A. veuillez fournir la preuve svp.</strong></span><br/>
                                            <span><strong>2:- Tous les frais bancaires sont à la charge du Client</strong></span><br/>
                                            <span><strong>3:- Tout Client acheteur des produits de sécurité/radio/rabx/réseau est tenu d'obtenir ses propres 
                                            </strong></span>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td width="35%" style="background-color: transparent !important;border-color:#ffffff;"></td>
                            
                        </tr>
                    </table>
                </div>
                <t t-if="page_index &lt; page_size - 1" groups="sale.group_sale_layout">
                    <p style="page-break-before:always;"> </p>
                </t>
            </t>
            <div class="oe_structure"/>
            
        </div>



            </t>
        </t>
    </t>
</template>

<template id="report_saleorder_pro_forma_t">
    <t t-call="web.html_container">
        <t t-foreach="docs" t-as="doc">
            <t t-call="sale_discount.report_invoicess" t-lang="doc.partner_id.lang"/>
        </t>
    </t>
</template>


    <template id="internal_layout_test">
        <!-- Multicompany -->
        <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>
        <div class="article">
          <t t-raw="0" />
        </div>

        <div class="footer" style="border-top:1px solid #000000">
            <div>
                <img class="img img-responsive" src="/sale_discount/static/img/partners.PNG" /> 
            </div> 
            <div class="text-center" style="border-top:1px dotted #000000">
                <ul class="list-inline mb4">
                    <li t-if="company.street"><span t-field="company.street"/></li>
                </ul>
                <ul class="list-inline mb4">
                    <li t-if="company.phone">Phone: <span t-field="company.phone"/></li>
                    <li t-if="company.email">Email: <span t-field="company.email"/></li>
                    <li t-if="company.website">Web: <span t-field="company.website"/></li>
                    <li t-if="company.vat"><t t-esc="company.country_id.vat_label or 'TIN'"/>: <span t-field="company.vat"/></li>
                </ul>

                <div name="financial_infos">
                    <span t-field="company.report_footer"/>
                </div>

                <div class="text-muted">
                    Page: <span class="page"/> / <span class="topage"/>
                </div>
            </div>
        </div>
    </template>


</odoo>

 


Avatar
Hylkää
Paras vastaus

Goto addons/web/views/report_templates.xml you can see the report_layout template inherit or override the same and do your needs. Include your div here and this will be used for all reports repeatedly, or make your div as a new template and call like header and footer did.

Avatar
Hylkää

I have created my div in other template and when i call using t-call it won't repeat.
Do you know why