跳至內容
選單
此問題已被標幟
1 回覆
5648 瀏覽次數


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
2635
1
6月 24
5102
1
10月 23
10795
1
10月 23
98
1
8月 23
2193