Odoo Help

Welcome!

This community 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.

3

How to create a custom import function in openerp?

By
willie ho
on 1/16/15, 1:54 AM 1,989 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
0
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+')

          fp.write(xls_data)

          fp.close()

          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...

Odoo
on 4/29/15, 6:26 AM
0
agb80
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

0
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. 

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. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

3 follower(s)

Stats

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