Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
5659 มุมมอง


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

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ค. 24
2650
1
มิ.ย. 24
5127
1
ต.ค. 23
10829
1
ต.ค. 23
98
413 Request Entity Too Large แก้ไขแล้ว
1
ส.ค. 23
2193