[FIX] openerp.modules.migration: do not shadow AttributeError that may occure when executing the migrate() function

bzr revid: chs@openerp.com-20130508104658-d2553vdx0etiuhpk
This commit is contained in:
Christophe Simonis 2013-05-08 12:46:58 +02:00
parent 54ad990e48
commit 4897f1740e
1 changed files with 5 additions and 5 deletions

View File

@ -3,7 +3,7 @@
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
# Copyright (C) 2010-2013 OpenERP s.a. (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -180,14 +180,14 @@ class MigrationManager(object):
try:
mod = imp.load_source(name, pyfile, fp2)
_logger.info('module %(addon)s: Running migration %(version)s %(name)s' % mergedict({'name': mod.__name__}, strfmt))
mod.migrate(self.cr, pkg.installed_version)
migrate = mod.migrate
except ImportError:
_logger.error('module %(addon)s: Unable to load %(stage)s-migration file %(file)s' % mergedict({'file': pyfile}, strfmt))
_logger.exception('module %(addon)s: Unable to load %(stage)s-migration file %(file)s' % mergedict({'file': pyfile}, strfmt))
raise
except AttributeError:
_logger.error('module %(addon)s: Each %(stage)s-migration file must have a "migrate(cr, installed_version)" function' % strfmt)
except:
raise
else:
migrate(self.cr, pkg.installed_version)
finally:
if fp:
fp.close()