This question has been flagged
2 Replies
17398 Views

I opened the invoice report using the OpenOffice OpenERP plugin. I changed the page format to landscape then sent it to the server. I took the opportunity to rename the report to Invoice Landscape, just so that I knew it had arrived. I refreshed the browser. Clicked the button to print the invoice. The browser shows "Still loading" for 15 minutes.

I have my doubts about this approach. There is a "Page Format" setting (Settings/Company/General Information/Page Format) which can be set either to A4 or Letter. Also the the RML of the header and footer is available for editing. If the Header is simply prepended to the report I've uploaded from OpenOffice then how will the header know to switch to Landscape?

If the OpenOffice upload changes to A4 page format but the OpenERP setting is Letter, who has precedence? I'm left to wonder about this because my uploads don't print.

Avatar
Discard
Best Answer

Update answer for Piotr Cierkosz:

To do this, you need to add Landscape into your custom paperformat, and then, call it in your report xml

Full code:





<!-- custom pager format -->
<record id="paperformat_student_report" model="report.paperformat">
<field name="name">Custom Paperformat for the Student report</field>
<field name="default" eval="False"/>
<field name="disable_shrinking" eval="True"/>
<field name="format">A4</field>
<field name="page_height">0</field>
<field name="page_width">0</field>
<!-- this one is to make the pdf to become horizontal, if landscape=False, pdf will become vertical -->
<field name="orientation">Landscape</field>
<field name="margin_top">0</field>
<field name="margin_bottom">8</field>
<field name="margin_left">0</field>
<field name="margin_right">0</field>
<field name="dpi">96</field>
</record>

<!-- pdf version -->
<record id="action_report_student" model="ir.actions.report" style="color:#e8bf6a;">>
<!-- this field will show as name of the button,
also will be the name of exported file, unless we use print_report_name as below -->
<field name="name">Students</field>
<field name="model">school.students</field>
<field name="report_type">qweb-pdf</field>
<!-- In single report, this print_report_name will be use as dynamic name of the file.
But in multiple reports, this will not work, it will use <field name="name"> as file name.
So we should use print_report_name for single report, and <field name="name"> to multiple reports.
-->
<field name="print_report_name">'Student - [%s]' % (object.sequence).replace('/', '')</field>
<!-- the view file is declare in this variable -->
<field name="report_name">school.report_student</field>
<!-- not sure what this for -->
<field name="report_file">school.report_student</field>
<!-- not sure what this for -->
<field name="binding_model_id" ref="model_school_students"/>
<field name="binding_type">report</field>
<!-- custom pager format -->
<field name="paperformat_id" ref="paperformat_student_report"/>
</record>

 



If you call report from a python code, then try this instead:

Add .with_context(landscape=True) to your py code:

Example:

report_action = self.env.ref('school.action_report_calendar').with_context(landscape=True).report_action(self, data=data)

Hope it helped.

Avatar
Discard
Best Answer

You can do it by changing the QWeb attribute called "Orientation":

<field name="orientation">Landscape</field>

Official documentation is here:

https://www.odoo.com/documentation/10.0/reference/reports.html#paper-format

 

Avatar
Discard