Jay Vora (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-client-web/6.0-bug-import-jvo into 
lp:openobject-client-web/6.0.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-bug-import-jvo/+merge/63212
-- 
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-bug-import-jvo/+merge/63212
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-client-web/6.0-bug-import-jvo.
=== modified file 'addons/openerp/controllers/impex.py'
--- addons/openerp/controllers/impex.py	2011-02-03 12:39:38 +0000
+++ addons/openerp/controllers/impex.py	2011-06-02 10:20:34 +0000
@@ -311,7 +311,6 @@
 
         ids = []
         context = context or {}
-
         fields_data = {}
         proxy = rpc.RPCProxy(model)
         fields = proxy.fields_get(False, rpc.session.context)
@@ -497,6 +496,9 @@
 
         try:
             for j, line in enumerate(csv.reader(input, quotechar=str(csvdel), delimiter=str(csvsep))):
+                #If the line contains no data,we should skip it
+                if not line:
+                    continue
                 if j == limit:
                     fields = line
                 else:
@@ -520,6 +522,13 @@
                 datas.append(map(lambda x:x.decode(csvcode).encode('utf-8'), line))
             except:
                 datas.append(map(lambda x:x.decode('latin').encode('utf-8'), line))
+        
+        #If the file contains nothing
+        if not datas:
+            error = {'message':_('The file is empty !'), 'title':_('Importation !')}
+            return self.imp(error=error, **kw)
+        
+        #Inverting the header into column names
         try:
             res = rpc.session.execute('object', 'execute', params.model, 'import_data', fields, datas, 'init', '', False, ctx)
         except Exception, e:

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to