fix bug with language update when upgrading a module + PEP8

bzr revid: christophe@tinyerp.com-20081024150743-4u8iolu21xhi0a2r
This commit is contained in:
Christophe Simonis 2008-10-24 17:07:43 +02:00
parent 6b87952e23
commit be2fe6fe1e
2 changed files with 10 additions and 17 deletions

View File

@ -604,9 +604,9 @@ class module(osv.osv):
if not filter_lang:
pool = pooler.get_pool(cr.dbname)
lang_obj=pool.get('res.lang')
lang_ids=lang_obj.search(cr, uid, [('translatable', '=', True)])
filter_lang= [lang.code for lang in lang_obj.browse(cr, uid, lang_ids)]
lang_obj = pool.get('res.lang')
lang_ids = lang_obj.search(cr, uid, [('translatable', '=', True)])
filter_lang = [lang.code for lang in lang_obj.browse(cr, uid, lang_ids)]
elif not isinstance(filter_lang, (list, tuple)):
filter_lang = [filter_lang]
@ -617,7 +617,7 @@ class module(osv.osv):
for lang in filter_lang:
f = os.path.join(tools.config['addons_path'], mod.name, 'i18n', lang + '.po')
if os.path.exists(f):
logger.notifyChannel("init", netsvc.LOG_INFO, 'addons %s: loading translation file for language %s' % (mod.name, lang))
logger.notifyChannel("init", netsvc.LOG_INFO, 'addon %s: loading translation file for language %s' % (mod.name, lang))
tools.trans_load(cr.dbname, f, lang, verbose=False)
module()

View File

@ -87,26 +87,19 @@ class wizard_info_get(wizard.interface):
db, pool = pooler.get_db_and_pool(cr.dbname)
cr = db.cursor()
mod_obj = pool.get('ir.module.module')
ids = mod_obj.search(cr, uid, [
('state', 'in', ['to upgrade', 'to remove', 'to install'])])
unmet_packages=[]
ids = mod_obj.search(cr, uid, [('state', 'in', ['to upgrade', 'to remove', 'to install'])])
unmet_packages = []
mod_dep_obj = pool.get('ir.module.module.dependency')
for mod in mod_obj.browse(cr,uid,ids):
depends_mod_ids=mod_dep_obj.search(cr,uid,[('module_id','=',mod.id)])
for dep_mod in mod_dep_obj.browse(cr,uid,depends_mod_ids):
for mod in mod_obj.browse(cr, uid, ids):
depends_mod_ids = mod_dep_obj.search(cr, uid, [('module_id', '=', mod.id)])
for dep_mod in mod_dep_obj.browse(cr, uid, depends_mod_ids):
if dep_mod.state in ('unknown','uninstalled'):
unmet_packages.append(dep_mod.name)
if len(unmet_packages):
raise wizard.except_wizard('Unmet dependency !','Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages))
raise wizard.except_wizard('Unmet dependency !', 'Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages))
mod_obj.download(cr, uid, ids, context=context)
cr.commit()
db, pool = pooler.restart_pool(cr.dbname, update_module=True)
# Update translations for all installed languages
cr = db.cursor()
modobj = pool.get('ir.module.module')
mids = modobj.search(cr, uid, [('state', '=', 'installed')])
modobj.update_translations(cr, uid, mids, None)
return {}
def _config(self, cr, uid, data, context=None):