Hello,
I'm very new to Odoo. I'm just trying to adapt the header and the footer of the external_layout_standard to fit my needs.
I have created a custom module with a new paper_format.xml and a header_footer.xml overriding the default header and footer from web.external_layout_standard by using XPATH replace.
So far I can load the module. When I do a modification, I restart the server, "update app list", upgrade my module and try to see the change by printing a "Quotation/Order" again.
What is strange and drives me nuts is that I have the feeling the template is not always loaded the same... For example, sometimes the company address is displayed, sometimes not, suddenly a page is printed twice...
I can't understand what I'm doing wrong.
Can anybody recommend me a good tutorial on how to design PDF template and to understand the logic on how a page is built?
Thank you in advance!
JC
share the code snippet please
This is the __manifest__.py:
# -*- coding: utf-8 -*-
{
'name': 'DD module',
'version': '1.0',
'summary': 'Mainly a header and footer for print report',
'description': '',
'category': 'Productivity',
'author': 'JCL',
'website': '',
'license': '',
'depends': ['web', 'base'],
'data': [
'reports/header_footer.xml',
'reports/paper_format.xml',
],
'demo': [''],
'installable': True,
'application': True,
'auto_install': False,
}
And this is the header_footer.xml:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="external_layout_standard_DD" inherit_id="web.external_layout_standard">
<!-- Custom Header for DD -->
<xpath expr="//div[1]" position="replace">
<div t-attf-class="header o_company_#{company.id}_layout" t-att-style="report_header_style">
<div class="row">
<div class="col-4 mb4">
<img t-if="company.logo" t-att-src="image_data_uri(company.logo)" style="max-height: 45px;" alt="Logo"/>
</div>
</div>
<div class="row">
<div class="col-4 mb4" name="company_address">
<div t-field="company.partner_id"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}' style="font-size:6px"
/>
</div>
</div>
</div>
<div t-attf-class="article o_report_layout_standard o_company_#{company.id}_layout" 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')">
<div class="pt-5">
<!-- This div ensures that the address is not cropped by the header. -->
<t t-call="web.address_layout"/>
</div>
<t t-raw="0"/>
</div>
</xpath>
<!-- Custom Footer for DD -->
<!-- Custom footer -->
<xpath expr="//div/div[hasclass('text-center')]" position="replace">
<div class="text-center" style="border-top: 1px solid black;">
<ul class="list-inline mb4 text-nowrap">
<li t-if="company.phone" class="list-inline-item d-inline">Phone: <span class="o_force_ltr" t-field="company.phone"/></li>
<li t-if="company.email" class="list-inline-item d-inline">Email: <span t-field="company.email"/></li>
<li t-if="company.website" class="list-inline-item d-inline">Web: <span t-field="company.website"/></li>
<li t-if="company.vat" class="list-inline-item d-inline"><t t-esc="company.country_id.vat_label or 'Tax ID'"/>: <span t-field="company.vat"/></li>
</ul>
</div>
</xpath>
</template>
</odoo>