This question has been flagged
3 Replies
1835 Views

Hii community,i'm new in odoo and i was trying to generate a simple report, i don't get any error, but when i press print report button from actions, not work


this is my model:

pdf_module

class pdf_temp(models.Model):    

    _name = 'pdf_module.pdf_temp'    

    _description = 'temp'
    

    name = fields.Char(string="name")


XML:

<   report

    string='Print Report'            

    model='pdf_module.pdf_temp'            

    report_type='qweb-pdf'            

    name='pdf_module.report_pdf_report'        

/ >


 < template id="report_pdf_report">           
 <
t-call="report.html_container">               
 < t-call="report.external_layout">                   
 < div class="page">                       
 <
p >This is a report< / p >                   
 < / div >               
 < / t >           
 < / t >       
 < / template>

   

can you give me any recommendation?


Avatar
Discard
Author

thanks but the same thing happens, the button does nothing

Best Answer

Hello Luis Ope,


Please find code in comment.

I hope this will help you. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard

Please find below code it may help you to resolve this issue,

class pdf_temp(models.Model):
_name = 'pdf_module.pdf_temp'
_description = 'temp'

name = fields.Char(string="name")

<record id="action_pdf_report" model="ir.actions.report">
<field name="name">Report Name</field>
<field name="model">pdf_module.pdf_temp</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">pdf_module.report_pdf_report</field>
<field name="report_file">pdf_module.report_pdf_report</field>
<field name="print_report_name">'PDF Report - %s' % (object.name)</field>
<field name="binding_model_id" ref="model_pdf_module_pdf_temp"/>
<field name="binding_type">report</field>
</record>

<template id="report_pdf_report">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="web.external_layout">
<div class="page">
<h2>Sample Report</h2>
<p>span t-field="o.name"/></p>
</div>
</t>
</t>
</t>
</template>

Author Best Answer

It doesn't work, I tried your recommendation but the problem persists, when I press the button it just doesn't do anything

Avatar
Discard
Best Answer

Hi,

Try like following.

<record id="action_for_report" model="ir.actions.report">


    <field name="name">Print Report</field>


    <field name="model">pdf_module.pdf_temp</field>


    <field name="report_type">qweb-pdf</field>


    <field name="report_file">pdf_module.report_pdf_report</field>


    <field name="report_name">pdf_module.report_pdf_report</field>


    <field name="binding_model_id" ref="Name of the module.model_pdf_module"/>


    <field name="binding_type">report</field>


</record>




<template id="report_pdf_report">


     <t t-call="web.html_container">


         < t-call="web.external_layout">


            < div class="page">                      


               < p >This is a report< / p >                  


            </div >        


         </t>


     </t>


</template>


Also you can refer the following blog for creating a basic pdf report in odooV15

https://www.cybrosys.com/blog/how-to-create-a-pdf-report-in-odoo-15

Hope it helps

Avatar
Discard