[FIX] cli/server: fixes #1307, add missing Environment management blocks

This commit is contained in:
Raphael Collet 2014-07-30 15:31:00 +02:00
parent 6c4cf84ce8
commit b8a0e65ed5
1 changed files with 12 additions and 12 deletions

View File

@ -112,13 +112,13 @@ def export_translation():
config["translate_out"]) config["translate_out"])
fileformat = os.path.splitext(config["translate_out"])[-1][1:].lower() fileformat = os.path.splitext(config["translate_out"])[-1][1:].lower()
buf = file(config["translate_out"], "w")
registry = openerp.modules.registry.RegistryManager.new(dbname) with open(config["translate_out"], "w") as buf:
cr = registry.cursor() registry = openerp.modules.registry.RegistryManager.new(dbname)
openerp.tools.trans_export(config["language"], with openerp.api.Environment.manage():
config["translate_modules"] or ["all"], buf, fileformat, cr) with registry.cursor() as cr:
cr.close() openerp.tools.trans_export(config["language"],
buf.close() config["translate_modules"] or ["all"], buf, fileformat, cr)
_logger.info('translation file written successfully') _logger.info('translation file written successfully')
@ -128,11 +128,11 @@ def import_translation():
dbname = config['db_name'] dbname = config['db_name']
registry = openerp.modules.registry.RegistryManager.new(dbname) registry = openerp.modules.registry.RegistryManager.new(dbname)
cr = registry.cursor() with openerp.api.Environment.manage():
openerp.tools.trans_load( cr, config["translate_in"], config["language"], with registry.cursor() as cr:
context=context) openerp.tools.trans_load(
cr.commit() cr, config["translate_in"], config["language"], context=context,
cr.close() )
def main(args): def main(args):
check_root_user() check_root_user()