I want to convert the ir.attachment file in the sales module into a PDF file using python. I have a custom report which needs to be added, no matter if Save as Attachment is set or not. Can you explain this briefly?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
Hello Nivetha,
Have you tried the old way?
import base64
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'
})
If you need more explanation go with this tutorial
https://www.cybrosys.com/blog/creating-pdf-attachment-automatically-odoo-13
Or older one:
https://medium.com/hendrasj/how-to-create-attachment-pdf-report-automatically-on-odoo-10-odoo-11-79dd3ad19f23
You will find a way that should work for you also in Odoo 15.
I you found it helpful please vote +1 👍
If it solves completely you problem - mark as best answer 😎
Hi,
Try refer the following number.
https://www.cybrosys.com/blog/how-to-create-pdf-attachment-automatically-in-odoo-15
Regards
Api to get pdf file preview:
@http.route(['/schedule_pdf'], type='http', auth="public", website=True, sitemap=False)
def schedule_pdf(self, **kw):
if kw.get('id'):
as_model = request.env['alwathba.schedule'].sudo().browse([int(kw.get('id'))])
content = base64.b64decode(str(as_model.pdf_file.decode("utf-8")))
pdfhttpheaders = [('Content-Type', 'application/pdf'),('Content-Length', u'%s' % len(content))]
return request.make_response(content, headers=pdfhttpheaders)
to access pdf: https://yourcompany.com/schedule_pdf?id=14
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
1
พ.ย. 21
|
5125 | ||
|
1
มิ.ย. 23
|
4885 | ||
|
0
พ.ย. 23
|
1206 | ||
|
1
พ.ย. 22
|
5427 | ||
|
0
ธ.ค. 21
|
3541 |