1
votes

im new in reporting qweb, i want to practice it, then i try to creat a report for my module gestion_des_etudiants, i know something is missing in my code, i need your help :

report_etudiant.xml

<?xml version="1.0" encoding="utf-8"?>
<!--Custom report.-->
<openerp>
    <data>
        <template id="report_etudiant_document">
            <t t-call="report.external_layout">
                <div class="page">
                <div class="row">
                    <h3>Teeeeeeeeeeeeest</h3>

                </div>
                </div>
            </t>
        </template>
        <template id="report_etudiant">
            <t t-call="report.html_container">
            <t t-foreach="doc_ids" t-as="doc_id">

               <h3>Tiiiiiiiiiiiiiiiiiiiiitle</h3>

        </t>
    </t>
</template>


    </data>
</openerp>

etudiant_report.xml :

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <report
            id="action_report_etudiant"
            string="Attestation de scolarité"
            model="etudiant"
            report_type="qweb-pdf"
            name="gestion_des_etudiants.report_etudiant"
            file="gestion_des_etudiants.report_etudiant"
        />
    </data>
</openerp>

And when i print the report, i get an empty pdf file, no errors but empty, not even header or footer

4
Can you please update the code with .py code to render the template.? Or try both of these codes in a single file combined..Usman Maqbool

4 Answers

2
votes

You are not calling your report_etudiant_document template to show what you need, so inside your t-foreach you need to add this line:

Edit:

<t t-raw="translate_doc(doc_id, doc_model, 'gestion_des_etudiants.report_etudiant_document')"/>

I hope this can help you!

1
votes

You can refer our blog on Qweb Report.

There we have describe everything in details.

1
votes

As you said, the report is generating but you can't see any pages. here, you have defind two templates.

To get the pages in a qweb-pdf, we must use these tags

<div class="page">
<div class="row">

In your code, you have defined two templates, in template-1 you have used

<div class="page">
<div class="row">

In template-2, you have not included the above two tags, and you configured the report action for the template-2

<report 
 id="action_report_etudiant" 
 string="Attestation de scolarité" 
 model="etudiant" 
 report_type="qweb-pdf" 
 name="gestion_des_etudiants.report_etudiant" 
 file="gestion_des_etudiants.report_etudiant" />

That's the reason its not printing.

So,either include the above div tags in template-2, or configure report action for template-1

0
votes
<?xml version="1.0" encoding="utf-8"?>
<!--Custom report.-->
<openerp>
    <data>
       <report
        id="action_report_etudiant"
        string="Attestation de scolarité"
        model="etudiant"
        report_type="qweb-pdf"
        name="gestion_des_etudiants.report_etudiant"
        file="gestion_des_etudiants.report_etudiant" />

        <template id="report_etudiant">
          <t t-call="report.external_layout">
          <t t-call="report.html_container">
          <div class="page">
             <t t-foreach="doc_ids" t-as="doc_id">
               <h3>Tiiiiiiiiiiiiiiiiiiiiitle</h3>
             </t>
          </div>
         </t>
        </t>
      </template>
    </data>
</openerp>