Skip to Content
Menú
This question has been flagged
1 Respondre
5621 Vistes


pdf = self.env['report'].sudo().get_pdf([invoice.id], 'account.report_invoice')
self.env['ir.attachment'].create({
    'name': 'Cats',
    'type': 'binary',
    'datas': base64.encodestring(pdf),
'res_model': 'account.invoice',
'res_id': invoice.id

    'mimetype': 'application/x-pdf'
})


In odoo10 we are using  get_pdf method to  get the data to create attachments so what is the equiavalent method in  odoo 11 ?.





Avatar
Descartar
Best Answer

You can write as following :

pdf = self.env.ref('account.account_invoices').sudo().render_qweb_pdf([invoice.id])[0]

        self.env['ir.attachment'].create({

        'name': 'Cats',

        'type': 'binary', 

'res_id':invoice.id,

'res_model':'account.invoice',

datas':base64.b64encode(pdf),

'mimetype': 'application/x-pdf',

'datas_fname':"" +(invoice.display_name)+".pdf"

        })

Avatar
Descartar
Autor

Thanks..

Related Posts Respostes Vistes Activitat
2
de jul. 24
2601
1
de juny 24
5068
1
d’oct. 23
10745
1
d’oct. 23
98
1
d’ag. 23
2193