Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
161 Widoki

Hello,

In Odoo 18, I generate reports from data of my own module. Every thing is OK except, if in my report template, I use:

<t t-call="web.external_layout">
my code
</t>


In the top left of the pdf there is my company logo, that is OK, and bellow "My Company" while my company has an other name.

I have two questions:

  1. How to have the correct company name?
  2. What template file I have to modify (inherit_id=xxx) to change the header or the footer of the web.external_layout?

Thanks in advance,

Boris

Awatar
Odrzuć
Autor Najlepsza odpowiedź

Thanks.
I found the solution.

Boris

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,


To fix the incorrect company name on your Odoo 18 reports, first, verify and correct the company's name and details in the Settings app under "Users & Companies > Companies." Ensure the correct company is also active for the user generating the report. If the issue persists, the report might be pulling the company name from a different context, requiring a code examination.


To customize the header and footer of the web.external_layout, create a new QWeb template in your module that inherits from web.external_layout. Use XPath expressions to target and replace the header and footer sections with your custom content. You can use HTML, CSS, and QWeb directives like t-field to dynamically display data. Remember to update your module's manifest, upgrade the module, and clear your browser cache to see the changes.


Try the following code.


<template id="your_module.report_external_layout_custom" inherit_id="web.external_layout">

            <xpath expr="//div[@class='header']" position="replace">

                <!-- Your custom header content here -->

                <div class="header">

                    <div class="row">

                        <div class="col-6">

                            <img t-if="company.logo" t-att-src="image_data_uri(company.logo)" style="max-height: 45px;" alt="Logo"/>

                        </div>

                        <div class="col-6 text-right">

                            <h4 t-field="company.name"/>

                        </div>

                    </div>

                </div>

            </xpath>

            <xpath expr="//div[@class='footer']" position="replace">

                <!-- Your custom footer content here -->

                <div class="footer">

                    <div class="text-center">

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

                    </div>

                </div>

            </xpath>

        </template>



Reference:-


* https://www.cybrosys.com/blog/how-to-create-a-pdf-report-in-odoo-18


Hope it helps

Awatar
Odrzuć