How to import excel file in field? | Odoo

How to import excel file in field?

Hello,

I want to import excel file in openerp how to ?

I have binary field where I have save excel file. now button click I want to import data from excel to field which in my form view.

I need to parse excel and convert to dict then will do write.

but any good feature with in openerp?

Thanks.

Zahin
Zahin
591
| 7 3 8
Asked on 5/30/13, 3:38 PM
0
vote
1565 Views

Hi,

see this topice Read Excel files from Python

Borni DHIFI
Borni DHIFI
4599
| 6 8 8
Answered On 5/30/13, 4:10 PM
0
vote

You can define on_cnange method, what would process uploaded file.

<field name="excelfile" on_change="on_file_load(excelfile)"/>

You need to write parsing method in your *.py file

def on_file_load(self, cr, uid, ids, excelfile, context=None):
    #do_something

In this case file would be parsed before you save object.

Alexander
Alexander
166
| 5 2 3
Answered On 5/30/13, 4:10 PM
-1
vote

Have you fixed already this, because this will gives base64 encode file.

Zahin
on 5/30/13, 4:31 PM

Try to use something like that.

excelfile = base64.decodestring(excelfile)

And don't forget make

import base64
Alexander
on 5/30/13, 4:42 PM

I have try

base64.decode(lead.data, open("newcsv.xls", "w")) workbook = xlrd.open_workbook("newcsv.xls")

but got traceback AttributeError: 'str' object has no attribute 'readline'

Zahin
on 5/30/13, 5:20 PM

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice.

Ask a Question

About This Forum

This community is for professionals and enthusiasts of our products and services.


Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 5/30/13, 3:38 PM
Seen: 1565 times
Last updated: 5/30/13, 4:10 PM