From d2b123c6c2a7f88431d97e41329e30a4e2cff06e Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Tue, 12 Aug 2014 12:58:10 +0200 Subject: [PATCH] [FIX] TypeError: unlink() got multiple values for keyword argument 'context' --- base_location_geonames_import/test/import.yml | 27 +++++++++++++++++++ .../wizard/geonames_import.py | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/base_location_geonames_import/test/import.yml b/base_location_geonames_import/test/import.yml index a500e3db3..66243d24a 100644 --- a/base_location_geonames_import/test/import.yml +++ b/base_location_geonames_import/test/import.yml @@ -25,3 +25,30 @@ ('country_id', '=', ref('base.it')) ], context=context) assert len(zip_ids) == 1, "There must be 1 'Isola Del Cantone'" +- + I create the wizard again +- + !record {model: better.zip.geonames.import, id: import_wizard_2, view: better_zip_geonames_import_form}: + country_id: base.it +- + I run the import again +- + !python {model: better.zip.geonames.import}: | + self.run_import(cr, uid, [ref('import_wizard_2')], context=context) +- + I check the data +- + !python {model: res.better.zip}: | + state_obj = self.pool['res.country.state'] + state_ids = state_obj.search(cr, uid, [ + ('code', '=', 'LG'), + ('country_id', '=', ref('base.it')), + ], context=context) + assert len(state_ids) == 1, "There must be 1 LG" + zip_ids = self.search(cr, uid, [ + ('name', '=', '16017'), + ('city', '=', 'Isola Del Cantone'), + ('state_id', '=', state_ids[0]), + ('country_id', '=', ref('base.it')) + ], context=context) + assert len(zip_ids) == 1, "There must be 1 'Isola Del Cantone'" diff --git a/base_location_geonames_import/wizard/geonames_import.py b/base_location_geonames_import/wizard/geonames_import.py index b4bba3924..ee125b6d5 100644 --- a/base_location_geonames_import/wizard/geonames_import.py +++ b/base_location_geonames_import/wizard/geonames_import.py @@ -106,7 +106,7 @@ class better_zip_geonames_import(models.TransientModel): % (res_request.status_code, url)) bzip_ids_to_delete = bzip_obj.search([('country_id', '=', country_id)]) if bzip_ids_to_delete: - bzip_obj.unlink(bzip_ids_to_delete) + bzip_ids_to_delete.unlink() logger.info( '%d better zip entries deleted for country %s' % (len(bzip_ids_to_delete), self.country_id.name))