Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I want to user upload excel file by "fields.Binary()";
when the user click a certain button, this excel file will be downloaded on server; and then use "xlrd.open_workbook(filename)" to get the excel data and do the next doings;
Odoo already have method for download file from binary data.
@http.route('/web/binary/saveas', type='http', auth="public")
def saveas(self, model, field, id=None, filename_field=None, **kw):
This method available on '/web/controllers/main.py'
You can use this method by pass parameter in url.
URL : localhost:8069/web/binary/saveas?model=ir.attachment&field=datas&filename_field=datas_fname&id=103
Using this url odoo will give you data of field datas from ir.attachment model of record id is 103.
------------------------- Code is For reading Excel file that store in Binary format--------------------------
from openerp import api, fields, models, _
from openpyxl import load_workbook
_name = "excel.read"
data_file_p = open('/tmp/test.xlsx','w')
wb = load_workbook('test.xlsx')
ws = wb['big_data']
for row in ws.rows:
for cell in row:
Hope this helps.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 7/17/16, 10:21 AM|
|Seen: 2410 times|
|Last updated: 7/20/16, 10:10 PM|