Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to save XLSX file to ir_attachment odoo

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)
Comment

PREVIOUS NEXT
Code Example
Python :: pythoni me numra 
Python :: get current file location 
Python :: how to add multiple dfs to excel sheet 
Python :: pickle save 
Python :: flask download a file 
Python :: line number in logging python 
Python :: python requests pass auth token 
Python :: python youtube video downloader 
Python :: Import "django.core.urlresolvers" could not be resolved 
Python :: how to input multiple integers in python 
Python :: python get words between two words 
Python :: FizzBuzz FizzBuzz is a well known programming assignment, asked during interviews. 
Python :: typingclub hack python 
Python :: apolatrix 
Python :: pyqt5 window size 
Python :: how to install threading module in python 
Python :: sort a pandas dataframe based on date and time 
Python :: python dynamic loop 
Python :: python logger format time 
Python :: changes not showing on website server odoo 
Python :: how to limit a long text in djagno 
Python :: removing new line character in python from dataframe 
Python :: upload multiple files streamlit 
Python :: rename one dataframe column python 
Python :: python check if string starting with substring from list ltrim python 
Python :: pair plot python 
Python :: how to re run code in python 
Python :: select only object columns pandas 
Python :: show image with ratio opencv python 
Python :: triangle pattern in python 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =