Odoo Help


How to create a custom import function in openerp?

willie ho
on 1/16/15, 1:54 AM 3,527 views

I want to create a custom page to let user send the file to server.

After receiving the file, openerp will create records into the database base on the value in the file

what should I do?

Hi, I can help you with that. I have created custom import module for bank statement import, bom import etc. The csv import is already there, but to import, for example, the product should already available in DB and no option to create products on the fly if not existing, while doing the import. So custom import functions are useful. In front end, the user just need to upload a file, rest of the import can be done according to our needs, by reading data from it. Also different file formats like csv, xls, qif etc can be done. Contact me: akhilpsivan@outlook.com. Because its difficult to paste few codes and make you understand the things.

Akhil P Sivan
on 4/30/15, 1:32 AM
Bipin rathod
On 4/29/15, 5:12 AM

If you want to import function, first clear which file extension are use for data like .CSV or .XLS.

anyways, you have to create a function and read the data from .CSV or .XLS file.

import tempfile

import xlrd

from xlrd import open_workbook

def import_data(self, cr, uid, ids, context=None):

          temp_path = tempfile.gettempdir()

          test_obj = self.pool.get('test.test')

          xls_data = base64.decodestring(xls_file)

          fp=open(temp_path+'/xsl_file.xls', 'wb+')



          wb = open_workbook(temp_path+'/xsl_file.xls')

          for sheet in wb.sheets():

               for rownum in range(sheet.nrows):

                   if rownum == 0:

                       header_list = sheet.row_values(rownum)



Hope this will help you alot

Can You Complete this Code...

on 4/29/15, 6:26 AM
On 4/28/15, 8:00 PM

If out of the box import function is not good enough for you, you could try with this module: https://www.youtube.com/channel/UCVH4PLttdt09h1Di4yA2aUA

Michael Thomas
On 4/28/15, 7:03 PM

The Import function already lets us upload a csv file to the server, and then creates records based on the value in the file.

If you want to customize this module, you will want to look in addons\base_import for the models and views to import. 

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 1/16/15, 1:54 AM
Seen: 3527 times
Last updated: 4/30/15, 1:32 AM