Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odpovědi
6513 Zobrazení

I'm trying to create two versions for reports, the view is exactly the same for both versions, but the orientation is different, one report is intended to be printed on A4  Portrait and the other on A4- Lanscape.

The problem is that Odoo always print both reports with the same paper size.

Avatar
Zrušit
Autor

Please anyone body provide me an idea to resolve this case

Nejlepší odpověď

hi everybody,

i'm encountring some issue with odoo 12 community  with paper format declaration: report are well generated and linked to the good paper format (verified on technical settings > reports ) but the output pdf is always A4 format.

it seems like the output is somewhere forced to A4.

if any one could help, it ld be graceful.


thanks in advance

Avatar
Zrušit

hello,

thanks for your hel, it was very helpful.

are you odoo developer ? have you any whatsapp number ?

regards


On 10/11/2020 11:00, Niyas Raphy wrote:
Nejlepší odpověď

Hi,

Please see this method of printing the reports in landscape mode from python code and see whether it helps: How To Print PDF Report In Landscape Mode From Code in Odoo

Sample:

def _print_report(self, data):
data = self.pre_print_report(data)
data['form'].update({'sort_selection': self.sort_selection})
return self.env.ref('account.action_report_journal').with_context(landscape=True).report_action(self, data=data)

Thanks

Avatar
Zrušit
Nejlepší odpověď

Hello Kitty,

You need to define separate paper format for both report and used in paperformat_id of report record

Foe Example :-

Potrait :-
<record id="paper_format_potrait" model="report.paperformat">
    <field name="name">A4 - Potrait</field>
    <field name="format">A4-P</field>
    <field name="orientation">Portrait</field>
    <field name="margin_top">45</field>
    <field name="margin_bottom">25</field>
    <field name="margin_left">7</field>
    <field name="margin_right">7</field>
    <field name="header_spacing">34</field>
    <field name="dpi">90</field>
</record>

<report
    string="report_menu_name"
    id="unique_id_for_report"
    model="model.name"
    report_type="qweb-pdf"
    name="module_name.report_template_id"
    file="module_name.report_template_id"/>

<record id="module_name.report_configuration_id" model="ir.actions.report.xml">
    <field name="paperformat_id" ref="module_name.paper_format_potrait"/>
</record>

Landscape :-
<record id="paper_format_landscape" model="report.paperformat">
    <field name="name">A4 - Landscape</field>
    <field name="format">A4-L</field>
    <field name="orientation">Landscape</field>
    <field name="margin_top">7</field>
    <field name="margin_bottom">7</field>
    <field name="margin_left">7</field>
    <field name="margin_right">7</field>
    <field name="header_spacing">10</field>
    <field name="dpi">90</field>
</record>

<report
    string="report_menu_name"
    id="unique_id_for_report"
    model="model.name"
    report_type="qweb-pdf"
    name="module_name.report_template_id"
    file="module_name.report_template_id"/>

<record id="module_name.report_configuration_id" model="ir.actions.report.xml">
    <field name="paperformat_id" ref="module_name.paper_format_landscape"/>
</record>


Hope it will helps you.
Thanks,

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
srp 19
9041
1
led 24
4952
1
srp 19
15060
0
led 24
1482