Skip to Content
Menu
This question has been flagged
2 Replies
1976 Views

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

Hi Vasilis Zartilas


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

Thanks

Avatar
Discard
Author

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>

Author

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
Discard
Related Posts Replies Views Activity
0
May 24
53
1
Jun 17
9037
0
May 24
824
1
Jun 19
5131
1
Dec 23
18366