Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
2781 Widoki

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!!


Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
lip 24
2939
4
paź 20
5716
1
mar 15
5362
1
kwi 24
32116
3
lut 24
12685