答案 0 :(得分:6)
您可以直接修改原始的页脚和页眉视图:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="external_layout_header" inherit_id="report.external_layout_header">
<!-- make here your template modifications as usual -->
</template>
<template id="external_layout_footer" inherit_id="account.external_layout_footer">
<!-- make here your template modifications as usual -->
</template>
</odoo>
原始页脚模板是这样的:
<template id="external_layout_footer">
<div class="footer">
<div class="text-center" style="border-top: 1px solid black;">
<ul t-if="not company.custom_footer" class="list-inline">
<t t-set="company" t-value="company.sudo()"/>
<li t-if="company.phone">Phone: <span t-field="company.phone"/></li>
<li t-if="company.fax and company.phone">&bull;</li>
<li t-if="company.fax">Fax: <span t-field="company.fax"/></li>
<li t-if="company.email and company.fax or company.email and company.phone">&bull;</li>
<li t-if="company.email">Email: <span t-field="company.email"/></li>
<li t-if="company.website and company.email or company.website and company.fax or company.website and company.phone">&bull;</li>
<li t-if="company.website">Website: <span t-field="company.website"/></li>
</ul>
<ul t-if="not company.custom_footer" class="list-inline" name="financial_infos">
<li t-if="company.vat">TIN: <span t-field="company.vat"/></li>
</ul>
<t t-if="company.custom_footer">
<span t-raw="company.rml_footer"/>
</t>
<ul class="list-inline">
<li>Page:</li>
<li><span class="page"/></li>
<li>/</li>
<li><span class="topage"/></li>
</ul>
</div>
</div>
</template>
原始标头模板是这样的:
<template id="external_layout_header">
<div class="header">
<div class="row">
<div class="col-xs-3">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 45px;"/>
</div>
<div class="col-xs-9 text-right" style="margin-top:20px;" t-field="company.rml_header1"/>
</div>
<div class="row zero_min_height">
<div class="col-xs-12">
<div style="border-bottom: 1px solid black;"></div>
</div>
</div>
<div class="row">
<div class="col-xs-6" name="company_address">
<span t-field="company.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
style="border-bottom: 1px solid black; display:inline-block;"/>
</div>
</div>
</div>
</template>
您可以为不同的模型制作不同的页脚和页眉
<t t-if="'model_name' in o and o.model_name == 'account_invoice'">
<!-- your custom footer or hedaer for invoices -->
</t>
但是,如果您要使用与这些完全不同的另一个,则需要创建外部布局模板的替代方案:
<!-- ORIGINAL -->
<template id="external_layout">
<!-- Multicompany -->
<t t-if="not o and doc">
<t t-set="o" t-value="doc"/>
</t>
<t t-if="o and 'company_id' in o">
<t t-set="company" t-value="o.company_id"></t>
</t>
<t t-if="not o or not 'company_id' in o">
<t t-set="company" t-value="res_company"></t>
</t>
<t t-call="report.external_layout_header" />
<t t-raw="0" />
<t t-call="report.external_layout_footer" />
</template>
<!-- CUSTOM -->
<template id="custom_external_layout">
<!-- Multicompany -->
<t t-if="not o and doc">
<t t-set="o" t-value="doc"/>
</t>
<t t-if="o and 'company_id' in o">
<t t-set="company" t-value="o.company_id"></t>
</t>
<t t-if="not o or not 'company_id' in o">
<t t-set="company" t-value="res_company"></t>
</t>
<t t-call="my_module.custom_external_layout_header" />
<t t-raw="0" />
<t t-call="my_module.custom_external_layout_footer" />
</template>
并在您的报告模板中使用它:
<template id="your_report_document">
<t t-call="my_module.custom_external_layout">
<div class="page">
<!-- your report content -->
</div>
</t>
</template>