Hi,
How can we create attachments for the model account.invoice from the other models and from the invoice itself.
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
How can we create attachments for the model account.invoice from the other models and from the invoice itself.
Thanks
From the account.invoice it self
pdf = self.env.ref('account.account_invoices').sudo().render_qweb_pdf([self.id])[0]
self.env['ir.attachment'].create({
'name': self.number + ".pdf",
'type': 'binary',
'res_id': self.id,
'res_model': 'account.invoice',
'datas': base64.b64encode(pdf),
'mimetype': 'application/x-pdf',
'datas_fname': self.number + ".pdf"
})
From other models
there should be a field in relation with account.invoice, here invoice_id
invoice_id = fields.Many2one('account.invoice')
pdf = self.env.ref('account.account_invoices').sudo().render_qweb_pdf([invoice_id.id])[0]
self.env['ir.attachment'].create({
'name': invoice_id.number + ".pdf",
'type': 'binary',
'res_id': invoice_id.id,
'res_model': 'account.invoice',
'datas': base64.b64encode(pdf),
'mimetype': 'application/x-pdf',
'datas_fname': invoice_id.number + ".pdf"
})
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
DaftarPost Terkait | Replies | Tampilan | Aktivitas | |
---|---|---|---|---|
|
7
Agu 20
|
6978 | ||
|
0
Feb 19
|
3112 | ||
Attach documents to products in website in odoo 12?
Diselesaikan
|
|
1
Nov 19
|
3032 | |
|
0
Apr 19
|
3115 | ||
ir.attachment res_*-fields NULL on save
Diselesaikan
|
|
1
Mar 19
|
5868 |