Skip to Content
Menú
This question has been flagged
2 Respostes
1961 Vistes

I'm using Odoo17 and I want to print PDF Report from Wizard. The Wizard works fine, when I click on the button that trigger the function to print the PDF it download a blank PDF. To keep things simple, I'm not gonna publish all the code. So basically here are my files :


wizard/wizard_model

class ModelWizard (models.TransientModel):
   _name = 'project.pdf.report'
   _description='display printed informations'
   
   info= fields.Char()
   
   def print_report(self):
     print(self.env.context)
     data = {
           'model_id': self.id,
           'form': self.env.context
       }

     return self.env.ref('my_addon.action_report_Pdf').report_action(None, data=data)

Then I got my action file :

report/ir_actions_report

   

       My PDF

       project.pdf.report

       qweb-pdf

       my_addon.my_pdf

       my_addon.my_pdf

       'Name

       

       report

   


And finally my template:

   

       

           

               

                   

                       

Sample Report

                   

               

           

       

   


I must have missed something. When the PDF is download the file got  name instead of . And page is blank, no header nor footer.

Could you help please ?

Thanks!!


Avatar
Descartar
Best Answer

Hi,

Please refer to our blog below to create a PDF report from the wizard

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

And if the issue in the header and footer still exists, It may be the issue in your wkhtmltopdf package so to fix it 

Please uninstall your current wkhtmltopdf package and install it again. You can use the below code

sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb

sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb

sudo apt install -f

And also Please verify that all the URLs in the system parameter is same as your URL Settings -> Technical -> parameters -> system parameters


On searching URL you can see the below options. verify the URLs are same as your URL


Hope it helps

Avatar
Descartar
Autor Best Answer

Merci pour votre réponse. J'ai une erreur maintenant :

odoo.addons.base.models.ir_qweb.QWebException : erreur lors du rendu du modèle

AttributeError : l'objet 'str' n'a pas d'attribut '_name'

Modèle : web.external_layout_boxed


Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de jul. 24
1916
4
d’oct. 20
5063
1
de març 15
4846
1
d’abr. 24
31275
3
de febr. 24
12148