Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
623 Visualizzazioni

Hi Folks,

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

Thanks

Rakesh 

Avatar
Abbandona
Risposta migliore

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.

Avatar
Abbandona
Risposta migliore

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.

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
feb 20
28965
1
set 15
7157
2
lug 25
1494
1
mar 25
1181
1
mar 25
1038