From 1bfc16bcf22571991763943e59c851d65984b072 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 24 Oct 2016 14:12:57 +0200 Subject: [PATCH] Allow to specify translatable languages in trytond-admin issue5961 review27711002 --- CHANGELOG | 1 + trytond/admin.py | 10 +++++----- trytond/commandline.py | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0385ca0b0c..42afece992 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Allow to specify translatable languages in trytond-admin * Add datetime_field on Reference * Merge Spanish's into Spanish (Latin American) * Do not check write access on model for wizard with groups diff --git a/trytond/admin.py b/trytond/admin.py index 3b0927eca4..96e42329bf 100644 --- a/trytond/admin.py +++ b/trytond/admin.py @@ -43,14 +43,14 @@ def run(options): lang = Table('ir_lang') cursor.execute(*lang.select(lang.code, where=lang.translatable == True)) - lang = [x[0] for x in cursor.fetchall()] + lang = set([x[0] for x in cursor.fetchall()]) main_lang = config.get('database', 'language') - if main_lang not in lang: - lang.append(main_lang) + lang.add(main_lang) else: - lang = None + lang = set() + lang |= set(options.languages) pool = Pool(db_name) - pool.init(update=options.update, lang=lang) + pool.init(update=options.update, lang=list(lang)) if options.update_modules_list: with Transaction().start(db_name, 0) as transaction: diff --git a/trytond/commandline.py b/trytond/commandline.py index cd0dfd252b..f3f09d5037 100644 --- a/trytond/commandline.py +++ b/trytond/commandline.py @@ -51,6 +51,8 @@ def get_parser_admin(): action='store_true', help="set the admin password") parser.add_argument("-m", "--update-modules-list", action="store_true", dest="update_modules_list", help="Update list of tryton modules") + parser.add_argument("-l", "--language", dest="languages", nargs='+', + default=[], metavar='CODE', help="Load language translations") parser.epilog = ('The first time a database is initialized ' 'or when the password is set, the admin password is read '