changeset 0bd5a6ee2ea3 in modules/country:default
details: https://hg.tryton.org/modules/country?cmd=changeset;node=0bd5a6ee2ea3
description:
        Create a zip entry for each subdivision found

        issue8852
        review266761002
diffstat:

 CHANGELOG             |   2 ++
 scripts/import_zip.py |  10 ++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r 16341a440d1b -r 0bd5a6ee2ea3 CHANGELOG
--- a/CHANGELOG Wed Dec 04 11:09:35 2019 +0100
+++ b/CHANGELOG Mon Feb 17 09:59:27 2020 +0100
@@ -1,3 +1,5 @@
+* Create a zip entry for each subdivision found
+
 Version 5.4.0 - 2019-11-04
 * Bug fixes (see mercurial logs for details)
 * Replace XML data by import script
diff -r 16341a440d1b -r 0bd5a6ee2ea3 scripts/import_zip.py
--- a/scripts/import_zip.py     Wed Dec 04 11:09:35 2019 +0100
+++ b/scripts/import_zip.py     Mon Feb 17 09:59:27 2020 +0100
@@ -81,10 +81,12 @@
     for row in pbar(list(csv.DictReader(
                     f, fieldnames=_fieldnames, delimiter='\t'))):
         country = get_country(row['country'])
-        subdivision = get_subdivision(row['country'], row['code1'])
-        zips.append(
-            Zip(country=country, subdivision=subdivision, zip=row['postal'],
-            city=row['place']))
+        for code in ['code1', 'code2', 'code3']:
+            subdivision = get_subdivision(row['country'], row[code])
+            if code == 'code1' or subdivision:
+                zips.append(
+                    Zip(country=country, subdivision=subdivision,
+                        zip=row['postal'], city=row['place']))
     Zip.save(zips)
 
 

Reply via email to