Steps to Print multiple qweb reports on single print button based on condition.

Steps to Print multiple qweb reports on single print button based on condition.

Let’s say we want to print quotation reports based on service type dropdown on single print button:

i)Manufacturing Service(includes entire manufacturing process cost)

ii)Labour Service(includes only labour cost)

 

Steps to follow:

1.create service type selection field in sale order class.

 

service_type = fields.Selection([(‘manufacturing_service’, ‘ManuFacturing Service’), (‘labour_service’, ‘Labour Service’)], string=’Service Type’, required=True)

 

  1. If user selects service type as ManuFacturing Service print button will print ManuFacturing Quotation Report and if  user selects service type as  Labour Service then  print button will print  Labour Quotation Report.

 

3.Create 2 templates.

i)ManuFacturing Quotation Report (template id: report_manufacturing_quotation_container)

ii)Labour Quotation Report.(template id: report_quotation_container_template)

 

4.Conditionally call quotation template based on service type. Add below code in one of the templates.

<template id=”report_manufacturing_quotation_template”>

<t t-call=”report.html_container”>

<t t-foreach=”docs” t-as=”o”>

<t t-if=”o.service_type==’manufacturing _service’>

<t t-call=”pettools.report_manufacturing_quotation_container”/>

<!–for service type = manufacturing –>

</t>

<t t-if=”o.service_type!=’manufacturing _service’>

<t t-call=”pettools.report_quotation_container_template”/>

<!–for service type = labour –>

</t>

</t>

</t>

</template>