diff options
| author | Olivier Dony <odo@openerp.com> | 2011-09-19 23:13:10 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2011-09-19 23:13:10 +0200 |
| commit | 33b913fb5639866b4fda1cccacfa6b7002783d35 (patch) | |
| tree | 2ed3e9913cedc785d05995af0bc7c63b0f19ff46 /openerp/addons/base/module/wizard/base_import_language.py | |
| parent | d4c8370d924b74734bb15fb5ca7f459ef07b8e46 (diff) | |
| parent | b2415915cd8c1619f833dfe524103003b4102b11 (diff) | |
[MERGE] allow overwriting existing terms when importing stand-alone translations
bzr revid: odo@openerp.com-20110919211310-zcndav9xmqm0c5df
Diffstat (limited to 'openerp/addons/base/module/wizard/base_import_language.py')
| -rw-r--r-- | openerp/addons/base/module/wizard/base_import_language.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/openerp/addons/base/module/wizard/base_import_language.py b/openerp/addons/base/module/wizard/base_import_language.py index d73cd0864a6..fdb9a177d8b 100644 --- a/openerp/addons/base/module/wizard/base_import_language.py +++ b/openerp/addons/base/module/wizard/base_import_language.py @@ -35,9 +35,12 @@ class base_language_import(osv.osv_memory): 'name': fields.char('Language Name',size=64 , required=True), 'code': fields.char('Code (eg:en__US)',size=5 , required=True), 'data': fields.binary('File', required=True), + 'overwrite': fields.boolean('Overwrite Existing Terms', + help="If you enable this option, existing translations (including custom ones) " + "will be overwritten and replaced by those in this file"), } - def import_lang(self, cr, uid, ids, context): + def import_lang(self, cr, uid, ids, context=None): """ Import Language @param cr: the current row, from the database cursor. @@ -45,8 +48,11 @@ class base_language_import(osv.osv_memory): @param ids: the ID or list of IDs @param context: A standard dictionary """ - + if context is None: + context = {} import_data = self.browse(cr, uid, ids)[0] + if import_data.overwrite: + context.update(overwrite=True) fileobj = TemporaryFile('w+') fileobj.write(base64.decodestring(import_data.data)) @@ -56,7 +62,7 @@ class base_language_import(osv.osv_memory): fileformat = first_line.endswith("type,name,res_id,src,value") and 'csv' or 'po' fileobj.seek(0) - tools.trans_load_data(cr, fileobj, fileformat, import_data.code, lang_name=import_data.name) + tools.trans_load_data(cr, fileobj, fileformat, import_data.code, lang_name=import_data.name, context=context) tools.trans_update_res_ids(cr) fileobj.close() return {} |
