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
2874 Widoki

How to set a page in landscape orientation in a report template that is originally in portrait orientation?


I have a custom report template and some pages need to be in Landscape orientation. How can I implement this?


report.xml file:




paperformats.xml file:




custom_report_template.xml file:




layout.xml file:





my_module file:

    def print_report(self):

        return self.env.ref('my_module.my_report').report_action(self)

Awatar
Odrzuć
Najlepsza odpowiedź

Hi Vasilis Zartilas


Try this way and add this paperformate id on your report action

Thanks

Awatar
Odrzuć
Autor

Hello Nikhil Nakrani,

Thank you for the response.

If I add this, it will convert the entire report to landscape. What I need, however, is one page from the report to be in landscape.

Thanks

yes so you need pass context in your code here
def print_report(self):
report_action = self.env.ref('my_module.my_report_template').report_action(self)
report_action['landscape_page'] = True
return report_action
based on this context inside your pdf layout in call based on landscap or portairt

<template id="my_internal_layout">
<t t-set="layout">standard</t>
<div class="page">
<t t-if="not landscape_page">
<t t-call="report.page"/>
</t>
<t t-if="landscape_page">
<t t-call="my_module.my_landscape_page_template"/>
</t>
</div>
</template>

Autor

Hello Nikhil Nakrani,

1. I have passed the paperformate ID for orientation="landscape" to my report action.
2. I have modified the def report_action(self) as you mentioned earlier.
3. However, based on the code you provided (id="my_internal_layout"), the template prints one of the two templates and, of course, in landscape orientation.

What am I doing wrong?

Thanks.

Najlepsza odpowiedź

Hi Zartilas,

You can refer to https://www.odoo.com/documentation/16.0/fr/developer/reference/backend/reports.html for building or customizing QWeb template reports


Hope it helps

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
maj 24
55
1
cze 17
9539
0
maj 24
1319
1
cze 19
5647
1
gru 23
19026