From d7e01b096c9e99516951d95ca55fa4e81ca03b85 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Sun, 1 Dec 2024 13:19:46 +0100 Subject: [PATCH] [FIX] base_location_geonames_import: Fixes for re-imports Befor this commit, there were 2 possible errors re-importing ZIPs: - If city names are changed on the import process (like capitalization), the code for detecting existing entries was not taking that into account, failing to find the city. - If there's more than one found result, using `discard` for removing the result from the ZIPs to remove gives an error. TT52020 --- base_location_geonames_import/wizard/geonames_import.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base_location_geonames_import/wizard/geonames_import.py b/base_location_geonames_import/wizard/geonames_import.py index db5d61b89be..2643642607c 100644 --- a/base_location_geonames_import/wizard/geonames_import.py +++ b/base_location_geonames_import/wizard/geonames_import.py @@ -60,7 +60,7 @@ def _domain_search_city_zip(self, row, city=False): def _select_city(self, row, country, state): return self.env["res.city"].search( [ - ("name", "=", row[2]), + ("name", "=", self.transform_city_name(row[2], country)), ("country_id", "=", country.id), ("state_id", "=", state.id), ], @@ -250,7 +250,7 @@ def _process_csv(self, parsed_csv, country): if zip_vals not in zip_vals_list: zip_vals_list.append(zip_vals) else: - old_zips.discard(zip_code.id) + old_zips -= set(zip_code.ids) zip_model.create(zip_vals_list) if not max_import: if old_zips: