تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
11679 أدوات العرض

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.

أفضل إجابة

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

أفضل إجابة

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. 

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال