1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from openerp import tools
23 from openerp.osv import osv, fields
24 from openerp.tools.translate import _
26 class base_language_install(osv.osv_memory):
27 """ Install Language"""
29 _name = "base.language.install"
30 _description = "Install Language"
32 'lang': fields.selection(tools.scan_languages(),'Language', required=True),
33 'overwrite': fields.boolean('Overwrite Existing Terms', help="If you check this box, your customized translations will be overwritten and replaced by the official ones."),
34 'state':fields.selection([('init','init'),('done','done')], 'Status', readonly=True),
40 def lang_install(self, cr, uid, ids, context=None):
43 language_obj = self.browse(cr, uid, ids)[0]
44 lang = language_obj.lang
46 modobj = self.pool.get('ir.module.module')
47 mids = modobj.search(cr, uid, [('state', '=', 'installed')])
48 if language_obj.overwrite:
49 context = {'overwrite': True}
50 modobj.update_translations(cr, uid, mids, lang, context or {})
51 self.write(cr, uid, ids, {'state': 'done'}, context=context)
53 'name': _('Language Pack'),
57 'res_model': 'base.language.install',
59 'context': dict(context, active_ids=ids),
60 'type': 'ir.actions.act_window',
62 'res_id': ids and ids[0] or False,
65 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: