Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
603 Vizualizări

Hi Folks,

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

Thanks

Rakesh 

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
feb. 20
28954
1
sept. 15
7148
2
iul. 25
1488
1
mar. 25
1174
1
mar. 25
1034