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

Hi Folks,

In Odoo 17, Is possible to Print two Different paper formats like A4 and 3inch. With the same Template Id?

Thanks

Rakesh 

形象
丢弃
最佳答案

Hi,


In Odoo 17, it is not directly possible to print two different paper formats (like A4 and 3-inch receipt) using the same QWeb report template ID without additional customization. 

This is because each report in Odoo is tightly linked to a single paper format through its report definition in XML.


* Use the Same Template Logic, but Define Two Reports


You define two reports with different report_name and paperformat_id, but reuse the same report.template_id.


1- A4 report action


<record id="action_report_A4" model="ir.actions.report">
<field name="name">A4 report</field>
<field name="model">model.model</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">module.report_template_id</field>
<field name="report_file">module.report_template_id</field>
<field name="paperformat_id" ref="module.paperformat_a4_paper_format"/>
<field name="binding_type">report</field>
</record>

       

2-  3 inch report action


<record id="action_report_3_inch" model="ir.actions.report">
<field name="name">3 in report</field>
<field name="model">model.model</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">module.report_template_id</field>
<field name="report_file">module.report_template_id</field>
<field name="paperformat_id" ref="module.paperformat_3_inch_paper_format"/>
<field name="binding_type">report</field>
</record>


After adding the 2 report actions, from your model, you can call the actions based on the condition


 def print_report(self):

    if a4_condition:
return self.env.ref('module.action_report_A4').report_action(self, data=data)
else:
return self.env.ref('module.action_report_3_inch').report_action(self, data=data)



Hope it helps.

形象
丢弃
最佳答案

Hello,

You can try https://apps.odoo.com/apps/modules/18.0/omni_print . With this module, you can choose a different paper size each time you print—unless you enable the 'Print Directly' option. See the screenshot below for reference.

形象
丢弃
相关帖文 回复 查看 活动
2
2月 20
28959
1
9月 15
7151
2
7月 25
1490
1
3月 25
1178
1
3月 25
1036