I generate XLSX file using xlsxwriter module and downloaded after generated, but what I need is to save the xlsx file in the attachment? #odoo 15
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
Hello Saleh Algarni
Hope this code block will work for you.
Please find code in Comment.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
from cStringIO import StringIO
import base64
workbook = xlsxwriter.Workbook('demo.xlsx')
worksheet = workbook.add_worksheet()
worksheet.set_column('A:A', 20)
# Code for XLSX
fp = StringIO()
workbook.save(fp)
fp.seek(0)
datas = base64.encodestring(fp.read())
file_name = "demo.xlsx"
attachment_data = {
'name':file_name,
'datas_fname':file_name,
'datas':datas,
'res_model':"modelname",
}
self.env['ir.attachment'].create(attachment_data)
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
RegistrarsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
0
ene 22
|
1992 | ||
|
1
feb 25
|
1073 | ||
|
1
may 23
|
4024 | ||
|
1
jul 19
|
4864 | ||
|
2
jun 23
|
8699 |
Thank you Jainesh,
I couldn't reply to your answer because of this stupid Karma. So your answer was helpful and inspired me to find the solution, but it will not work on Python 3, the following code is worked on Python 3: