Skip to Content
Menú
This question has been flagged
2 Respostes
2844 Vistes

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
Descartar
Best Answer

Hi Vasilis Zartilas


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

Thanks

Avatar
Descartar
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.

Best Answer

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
Descartar
Related Posts Respostes Vistes Activitat
0
de maig 24
55
1
de juny 17
9527
0
de maig 24
1286
1
de juny 19
5638
1
de des. 23
19010