Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to add page number in Qweb reports in odoo

By
Gopakumar N G
on 2/2/15, 12:42 AM 5,944 views

How to add page numbers as page X of Y in Qweb reports in odoo.

Have you tried my solution below? If it helps, please upvote.

Cliff Kujala
on 2/3/15, 7:17 PM
2
Cliff Kujala
On 2/2/15, 3:11 AM

Try this:

<span>Page </span><span class="page" /> of <span class="topage" />

But keep in mind, this will only work when the report type is PDF, not HTML.

I am not using external_layout_footer in my Sales Order/Quote or Invoice Qweb report printouts. I instead have the header and footer written directly into the "document" Qweb views. My footer looks like this, which will give you a nice small Page Y of X in the lower left corner of the page.

<div class="footer">
            <div class="row">
                <div class="col-xs-2 pull-left">
                    <small>
                        <span>Page</span>
                        <span class="page" />
                        of
                        <span class="topage" />
                    </small>
                </div>
            </div>
        </div>

Try this out for a header:

<div class="header">
            <div class="row">
                <div class="col-xs-3">
                    <!-- <img t-if="o.company_id.logo" t-att-src="'data:image/png;base64,%s' % o.company_id.logo" style="max-height: 125px;"/> -->
                </div>
                <small>
                <div class="col-xs-2 text-right">
                    <div t-field="o.company_id.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}"/>
                </div>
                <div class="col-xs-2">
                    <div t-field="o.company_id.partner_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;phone&quot;, &quot;website&quot;, &quot;email&quot;], &quot;no_marker&quot;: true}"/>
                </div>
                </small>
                <div class="col-xs-4">
                    <span class="text-right">
                        <h4>
                            <span t-if="o.state not in ['draft','sent']">Order N°</span>
                            <span t-if="o.state in ['draft','sent']">Quote N°</span>
                            <span t-field="o.name" />
                        </h4>
                    </span>
                    <small>
                        <div class="row">
                            <div class="col-xs-8 text-right">
                                <span t-if="o.state not in ['draft','sent']">Order Date</span>
                                <span t-if="o.state in ['draft','sent']">Quote Date</span>
                            </div>
                            <div class="col-xs-4 text-right">
                                <span t-field="o.date_order" t-field-options="{&quot;format&quot;: &quot;yyyy-MM-dd&quot;}" />
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-8 text-right">
                                <span t-if="o.write_date">Modified Date</span>
                            </div>
                            <div class="col-xs-4 text-right">
                                <span t-field="o.write_date" t-field-options="{&quot;format&quot;: &quot;yyyy-MM-dd&quot;}" />
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-8 text-right">
                                <span t-if="o.user_id.name">Salesperson</span>
                            </div>
                            <div class="col-xs-4 text-right">
                                <span t-field="o.user_id.name" />
                            </div>
                        </div>
                    </small>
                </div>
            </div>
            <div class="row">
            <small>
                <div class="col-xs-2">
                    <strong>Customer</strong>
                    <div t-field="o.partner_invoice_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}" />
                </div>
                <div class="col-xs-2">
                    <strong>Contact</strong>
                    <div t-field="o.partner_invoice_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;phone&quot;, &quot;mobile&quot;, &quot;email&quot;], &quot;no_marker&quot;: true}" />
                </div>
                <div class="col-xs-2">
                    <strong>Shipping Address</strong>
                    <div t-if="o.partner_shipping_id == o.partner_invoice_id">Same as billing</div>
                    <div t-if="o.partner_shipping_id != o.partner_invoice_id">
                        <div t-field="o.partner_shipping_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;, &quot;phone&quot;], &quot;no_marker&quot;: true}" />
                    </div>
                </div>
                <div class="col-xs-6">
                    <!-- rest of customer ref info -->
                    <strong t-if="o.state not in ['draft','sent']">Order Terms</strong>
                    <strong t-if="o.state in ['draft','sent']">Quote Terms</strong>
                    <div class="row">
                        <div class="col-xs-6">
                            <div t-if="o.client_order_ref">
                                PO / Ref:
                                <span t-field="o.client_order_ref" />
                            </div>
                            <div t-if="o.payment_term">
                                Term:
                                <span t-field="o.payment_term" />
                            </div>
                            <div t-if="o.incoterm">
                                Incoterm:
                                <span t-field="o.incoterm" />
                            </div>
                            <div t-if="o.carrier_id">
                                Delivery Method:
                                <span t-field="o.carrier_id" />
                            </div>
                        </div>
                        <div class="col-xs-6">
                            <div t-if="o.state in ['draft','sent']">
                                <div t-if="o.validity_date">
                                    Expiry Date:
                                    <span t-field="o.validity_date" t-field-options="{&quot;format&quot;: &quot;yyyy-MM-dd&quot;}" />
                                </div>
                            </div>
                            <div t-if="o.requested_date">
                                Requested Date:
                                <span t-field="o.requested_date" t-field-options="{&quot;format&quot;: &quot;yyyy-MM-dd&quot;}" />
                            </div>
                            <div t-if="o.state">
                                Status:
                                <span t-field="o.state" />
                            </div>
                        </div>
                    </div>
                
                </div>
            </small>
            </div>
</div>

Does this work everywhere on the report? This line seemed to display the page number only when it was placed in the external_layout_footer template.

Shawn Varghese
on 2/2/15, 3:20 AM

I am not using external_layout_footer in my Sales Order/Quote or Invoice Qweb report printouts. I instead have the header and footer written directly into the "document" Qweb views. My footer looks like this:

Cliff Kujala
on 2/2/15, 3:24 AM

Post it as an answer... that part supports markup

Shawn Varghese
on 2/2/15, 4:15 AM

@Cliff Kujala Is it possible to add the header in all pages of the report?

Gopakumar N G
on 2/3/15, 11:43 PM

@ Gopakumar N G Yes this is possible. I will edit my answer above so you can see the code to add a header inside the "document" Qweb view.

Cliff Kujala
on 2/3/15, 11:48 PM

Are you viewing as PDF or HTML? It will only work as PDF. You also need to make sure you are calling out the class of the span tag correctly. See html/xml as written above. Anything that doesn't pass strict XML won't work.

Cliff Kujala
on 2/3/15, 11:55 PM

@Cliff Kujala For getting the header in all pages of the report, the div with class="header"is to be added in which part of the report? Could you please provide your report file or post it in the answer?

Gopakumar N G
on 2/4/15, 12:27 AM
3

Vasanth

--Vasanth--
3458
| 5 3 8
Pondicherry, India
--Vasanth--
Vasanth
On 2/4/15, 3:03 AM

Try this in xml.view:

<template id="external_layout_footer">
    <div class="footer">
        <div class="text-center" style="border-top: 1px solid black;">        

            <ul class="list-inline">
                <li>Page:</li>
                <li><span class="page"/></li>
                <li>/</li>
                <li><span class="topage"/></li>
            </ul>
        </div>
    </div>     

</template>

Thanks @vasanth this code very helpfull for me

Ankit H Gandhi(AHG)
on 2/4/15, 4:27 AM

How i can img to footer, i have my own module but i can add images with the images do not show up.

Carlos
on 11/20/15, 1:50 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 2/2/15, 12:42 AM
Seen: 5944 times
Last updated: 3/16/15, 8:10 AM