Speedup import process

This commit is contained in:
Sergi Almacellas Abellana 2015-01-21 19:02:55 +01:00
parent 2087a23ea4
commit 49db9449ef
1 changed files with 10 additions and 1 deletions

View File

@ -52,6 +52,7 @@ class LoadCountryZips(Wizard):
error_description_args=('bank.csv', e))
rows.next()
to_create, to_write = [], []
for row in rows:
if not row:
continue
@ -72,6 +73,14 @@ class LoadCountryZips(Wizard):
zip_.subdivision = subdivision
zip_.city = row[1]
zip_.save()
if zip_.id > 0:
to_write.extend(([zip_], zip_._save_values))
else:
to_create.append(zip_)
# Can Use save multi on version > 3.5
if to_create:
CountryZip.create([c._save_values for c in to_create])
if to_write:
CountryZip.write(*to_write)
return 'end'