From 25188692f9707a3c6422ad7077d5d0d478cf51cb Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 7 Apr 2014 18:51:17 +0200 Subject: [PATCH] Allow to skip entries in the _prepare method. --- base_location_geonames_import/wizard/geonames_import.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/base_location_geonames_import/wizard/geonames_import.py b/base_location_geonames_import/wizard/geonames_import.py index d94a60e7c..aef0ee533 100644 --- a/base_location_geonames_import/wizard/geonames_import.py +++ b/base_location_geonames_import/wizard/geonames_import.py @@ -47,6 +47,8 @@ class better_zip_geonames_import(orm.TransientModel): state_id = False if states and row[4] and row[4] in states: state_id = states[row[4].upper()] + if row[0] == 'FR' and 'CEDEX' in row[1]: + return False vals = { 'name': row[1], 'city': row[2], @@ -65,13 +67,12 @@ class better_zip_geonames_import(orm.TransientModel): _("The content of the file doesn't correspond to the " "selected country.")) logger.debug('ZIP = %s - City = %s' % (row[1], row[2])) - if row[0] == 'FR' and 'CEDEX' in row[1]: - return False if row[1] and row[2]: vals = self._prepare_better_zip( cr, uid, row, country_id, states, context=context) - bzip_id = self.pool['res.better.zip'].create( - cr, uid, vals, context=context) + if vals: + bzip_id = self.pool['res.better.zip'].create( + cr, uid, vals, context=context) return bzip_id def run_import(self, cr, uid, ids, context=None):