Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5626 Lượt xem


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





Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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"

        })

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks..

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 24
2606
1
thg 6 24
5069
1
thg 10 23
10749
1
thg 10 23
98
1
thg 8 23
2193