İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
2875 Görünümler

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)

Avatar
Vazgeç
En İyi Yanıt

Hi Vasilis Zartilas


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

Thanks

Avatar
Vazgeç
Üretici

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>

Üretici

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.

En İyi Yanıt

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

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
0
May 24
55
1
Haz 17
9539
0
May 24
1319
1
Haz 19
5647
1
Ara 23
19026