orm: at csv import, properly report lines with less columns

The "if not line[i]" check would cause an IndexError earlier than the
exception. Also, report the line number where that happened.
(the +2 op. is needed because we skip 1 for header and count at 0)
(cherry picked from commit 7f7e84e32405d4552b8f1b156d359d629bbca353)

bzr revid: p_christ@hol.gr-20110420152413-knedwepb0tmersw4
This commit is contained in:
P. Christeas 2011-04-20 18:24:13 +03:00
parent 2703b86ef3
commit 289ebadbb4
1 changed files with 4 additions and 2 deletions

View File

@ -762,10 +762,12 @@ class orm_template(object):
done = {}
for i in range(len(fields)):
res = False
if i >= len(line):
raise Exception(_('Please check that all your lines have %d columns.'
'Stopped around line %d having %d columns.') % \
(len(fields), position+2, len(line)))
if not line[i]:
continue
if i >= len(line):
raise Exception(_('Please check that all your lines have %d columns.') % (len(fields),))
field = fields[i]
if field[:len(prefix)] <> prefix: