Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
2275 Vistas

My report appears to be empty with no details showing. I'm not sure why this is happening as there are no error messages displayed. How can I troubleshoot this issue?


Could somebody lend me a hand with this?

Avatar
Descartar
Autor

employee_details.xml file in reports

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_employees">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="employee">
<t t-call="web.external_layout">
<div class="page">
<div class="oe_structure">
<h2>Employee Details</h2>
<p>Name: <t t-esc="employee.name"/></p>
<p>Email: <t t-esc="employee.email"/></p>
</div>
</div>
</t>
</t>
</t>
</template>
</odoo>

Action within the report area is

<record id="action_report_product_templates" model="ir.actions.report">
<field name="name">Employee Details</field>
<field name="model">employee.details.report.wizard</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">gb_custom_hr.report_employees</field>
<field name="report_file">gb_custom_hr.report_employees</field>
<field name="print_report_name">'Employee Report - %s' % (object.name)</field>
<field name="binding_model_id" ref="model_employee_details_report_wizard"/>
<field name="binding_type">report</field>
</record>

model in wizard

from odoo import fields, models, api

class EmployeeReportWizard(models.TransientModel):
_name = "employee.details.report.wizard"
_description = "Search Employee Details Wizard"

name = fields.Many2one('hr.employee', string="Name")
date_from = fields.Date(string="Date From")
date_to = fields.Date(string="Date To")

def action_print_report(self):
data = {
#'form': self.read()[0],
}
return self.env.ref('gb_custom_hr.action_report_product_templates').report_action(self, data=data)

Autor

The entire pdf is blank while using the wizard. If it prints without the wizard, it contains all the contents.

Autor

Can anyone know, how to solve it.

Mejor respuesta

Hi,

Please ensure that the data passed to your XML template from the Python wizard is correct. Print and verify the format of the data being provided to the XML template,Maybe its not be an object, it may be dictionary values, if so you need to call the values in the template as key indexes

example:

<p>Name: <t t-esc="employee['name']"/></p>


Please refer to our below blogs 

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


Hope it helps

Avatar
Descartar
Autor

Even if I removed the name and email. Still showing the blank report. Not even showing the heading.

Mejor respuesta

Hi,

Hope you have the expected data to print in the report, ensure it by printing the variable data in the log. If yes, check for the version of wkhtmltopdf installed.

FYI on wkhtmltopdf

Create and Print PDF Report From Wizard in Odoo

Thanks

Avatar
Descartar
Autor

Without using the wizard, they work well. But after applying the wizard, it became blank.

Okay, Just verify your code referring to the above video tutorial

Autor

The entire pdf is blank while using the wizard. And pdf displaying the details without wizard

Autor

Hi Savya,
In the logs nothing is showing while try to print it as shown in video
print("kkkkk--->", self.read()[0])

which means valid data is not passed and hence it shows a blank doc.
try,
print("kkkkk--->", self.sudo().read())

Autor

Hi Savya,
Still same, no change at all

Autor

wkhtmltox_0.12.5-1.bionic_amd64.deb this one is available.