コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5645 ビュー


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 ?.





アバター
破棄
最善の回答

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"

        })

アバター
破棄
著作者

Thanks..

関連投稿 返信 ビュー 活動
2
7月 24
2624
1
6月 24
5097
1
10月 23
10785
1
10月 23
98
1
8月 23
2193