Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
610 Lượt xem

Hi Folks,

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

Thanks

Rakesh 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 2 20
28956
1
thg 9 15
7150
2
thg 7 25
1490
1
thg 3 25
1178
1
thg 3 25
1036