Skip to Content
Menú
This question has been flagged
3 Respostes
3011 Vistes

is there a way to print and get invoice report in the chatter without download it 

Avatar
Descartar
Autor Best Answer

Hi it's solved

so to do it there is a function that call the pdf report without download it
render_qweb_pdf()

and i have do it like this :

import base64

    pdf = self.env.ref('account.YOUR REPORT NAME HERE').sudo().render_pdf(self.id)[0] 

    pdf = base64.b64encode(pdf)

#here to get the attachement bewlo your invoice instead of the chatter
    self.env['.ir.attachment'].create({'name':self.number or self.name,

                                                    'name': num,
                                                     'type': 'binary',
                                                      'datas': base64.encodestring(pdf),
                                                      'res_model': 'account.invoice',
                                                      'res_id': self.id,
                                                      'mimetype': 'application/x-pdf',
                                                                    })

 

Avatar
Descartar