2010-08-27 06:03:18 +00:00
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import tools
from osv import osv , fields
class base_language_install ( osv . osv_memory ) :
""" Install Language """
_name = " base.language.install "
2010-10-04 14:33:36 +00:00
_inherit = " ir.wizard.screen "
2010-08-27 06:03:18 +00:00
_description = " Install Language "
_columns = {
2010-10-04 14:33:36 +00:00
' lang ' : fields . selection ( tools . scan_languages ( ) , ' Language ' , required = True ) ,
2010-10-17 18:55:10 +00:00
' overwrite ' : fields . boolean ( ' Overwrite Existing Terms ' , help = " If you check this box, your customized translations will be overwritten and replaced by the official ones. " ) ,
2010-10-04 14:33:36 +00:00
' state ' : fields . selection ( [ ( ' init ' , ' init ' ) , ( ' done ' , ' done ' ) ] , ' state ' , readonly = True ) ,
}
2010-10-17 18:55:10 +00:00
_defaults = {
2010-10-04 14:33:36 +00:00
' state ' : ' init ' ,
2010-10-17 15:43:35 +00:00
' overwrite ' : False
2010-08-27 06:03:18 +00:00
}
2010-11-16 15:06:07 +00:00
def lang_install ( self , cr , uid , ids , context = None ) :
if context is None :
context = { }
2010-08-27 06:03:18 +00:00
language_obj = self . browse ( cr , uid , ids ) [ 0 ]
lang = language_obj . lang
if lang :
modobj = self . pool . get ( ' ir.module.module ' )
mids = modobj . search ( cr , uid , [ ( ' state ' , ' = ' , ' installed ' ) ] )
2010-10-17 15:43:35 +00:00
if language_obj . overwrite :
context = { ' overwrite ' : True }
modobj . update_translations ( cr , uid , mids , lang , context or { } )
2010-10-04 14:33:36 +00:00
self . write ( cr , uid , ids , { ' state ' : ' done ' } , context = context )
return False
2010-08-27 06:03:18 +00:00
base_language_install ( )
2010-10-17 15:43:35 +00:00
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: