跳至内容
菜单
此问题已终结
2 回复
2878 查看

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)

形象
丢弃
最佳答案

Hi Vasilis Zartilas


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

Thanks

形象
丢弃
编写者

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>

编写者

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.

最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
0
5月 24
55
1
6月 17
9539
0
5月 24
1321
1
6月 19
5648
1
12月 23
19028