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

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.

形象
丢弃
编写者

Please anyone body provide me an idea to resolve this case

最佳答案

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

形象
丢弃

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:
最佳答案

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

形象
丢弃
最佳答案

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,

形象
丢弃
相关帖文 回复 查看 活动
3
8月 19
9116
1
1月 24
5057
1
8月 19
15112
0
1月 24
1561