{"id":9354,"date":"2024-10-22T07:39:48","date_gmt":"2024-10-22T07:39:48","guid":{"rendered":"https:\/\/www.infinitivehost.com\/knowledge-base\/?p=9354"},"modified":"2024-10-22T07:39:50","modified_gmt":"2024-10-22T07:39:50","slug":"show-header-first-page-footer-last-page-in-odoo-14","status":"publish","type":"post","link":"https:\/\/www.infinitivehost.com\/knowledge-base\/show-header-first-page-footer-last-page-in-odoo-14\/","title":{"rendered":"Show Header First Page &amp; Footer Last Page in Odoo 14"},"content":{"rendered":"<div class='epvc-post-count'><span class='epvc-eye'><\/span>  <span class=\"epvc-count\"> 2,872<\/span><span class='epvc-label'> Views<\/span><\/div>\n<p>In Odoo 14, if you want to display a header only on the first page and a footer only on the last page in a QWeb report, you can achieve this by using conditions in your QWeb template. Here\u2019s a general approach:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example QWeb Template<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Define the Header and Footer<\/strong>:<br>Create the header and footer sections within the QWeb template. Use conditional logic to ensure the header is displayed only on the first page and the footer only on the last page.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;template id=\"report_your_report_name\">\n    &lt;t t-call=\"web.html_container\">\n        &lt;t t-foreach=\"docs\" t-as=\"doc\">\n            &lt;div class=\"page\">\n                &lt;!-- Header -->\n                &lt;t t-if=\"loop.index == 0\">\n                    &lt;div class=\"header\">\n                        &lt;h1>Your Header Content&lt;\/h1>\n                    &lt;\/div>\n                &lt;\/t>\n\n                &lt;!-- Main Content -->\n                &lt;div class=\"content\">\n                    &lt;h2 t-esc=\"doc.name\" \/>\n                    &lt;!-- Add more content as needed -->\n                &lt;\/div>\n\n                &lt;!-- Footer -->\n                &lt;t t-if=\"loop.index == docs|length - 1\">\n                    &lt;div class=\"footer\">\n                        &lt;h3>Your Footer Content&lt;\/h3>\n                    &lt;\/div>\n                &lt;\/t>\n            &lt;\/div>\n        &lt;\/t>\n    &lt;\/t>\n&lt;\/template><\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Explanation<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">&lt;t t-foreach=\"docs\" t-as=\"doc\"><\/mark><\/code><\/strong>: Iterates through the document records.<\/li>\n\n\n\n<li><strong><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">loop.index == 0<\/mark><\/code><\/strong>: Checks if the current loop iteration is the first one to display the header.<\/li>\n\n\n\n<li><strong><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">loop.index == docs|length - 1<\/mark><\/code><\/strong>: Checks if the current loop iteration is the last one to display the footer.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">CSS for Page Breaks<\/h3>\n\n\n\n<p>To ensure proper page breaks and layout, you might want to add some CSS:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;style>\n    .page {\n        page-break-after: always;\n    }\n    .header, .footer {\n        position: fixed;\n        width: 100%;\n    }\n    .header {\n        top: 0;\n    }\n    .footer {\n        bottom: 0;\n    }\n&lt;\/style><\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>This setup ensures that your report will show the header only on the first page and the footer only on the last page. Adjust the styling and content as needed for your specific requirements. If you encounter any issues, make sure to check the Odoo documentation or community forums for further assistance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2,872 Views In Odoo 14, if you want to display a header only on the first page and a footer only on the last page in a QWeb report, you can achieve this by using conditions in your QWeb template. Here\u2019s a general approach: Example QWeb Template Explanation CSS for Page Breaks To ensure proper [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[203],"tags":[],"class_list":["post-9354","post","type-post","status-publish","format-standard","hentry","category-odoo"],"_links":{"self":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=9354"}],"version-history":[{"count":1,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9354\/revisions"}],"predecessor-version":[{"id":9355,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9354\/revisions\/9355"}],"wp:attachment":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=9354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=9354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=9354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}