Exemplo n.º 1
0
 def _get_language(self, cr, uid, context):
     lang_obj = self.pool.get("res.lang")
     lang_ids = lang_obj.search(cr, uid, [("translatable", "=", True)], context=context)
     langs = lang_obj.browse(cr, uid, lang_ids, context=context)
     res = [(lang.code, lang.name) for lang in langs]
     for lang_dict in tools.scan_languages():
         if lang_dict not in res:
             res.append(lang_dict)
     return res
Exemplo n.º 2
0
 def _get_language(self, cr, uid, context):
     lang_obj = self.pool.get('res.lang')
     lang_ids = lang_obj.search(cr, uid, [],
             context=context)
     langs = lang_obj.read(cr, uid, lang_ids, ['code', 'name'], context=context)
     res = [(lang['code'], lang['name']) for lang in langs]
     for lang_dict in tools.scan_languages():
         if lang_dict not in res:
             res.append(lang_dict)
     return res
Exemplo n.º 3
0
 def _get_language(self, cr, uid, context):
     lang_obj = self.pool.get('res.lang')
     lang_ids = lang_obj.search(cr, uid, [('translatable', '=', True)],
             context=context)
     langs = lang_obj.browse(cr, uid, lang_ids, context=context)
     res = [(lang.code, lang.name) for lang in langs]
     for lang_dict in tools.scan_languages():
         if lang_dict not in res:
             res.append(lang_dict)
     return res
class base_language_install(osv.osv_memory):
    """ Install Language"""

    _name = "base.language.install"
    _description = "Install Language"
    _columns = {
        'lang':
        fields.selection(tools.scan_languages(), 'Language', required=True),
        'overwrite':
        fields.boolean(
            'Overwrite Existing Terms',
            help=
            "If you check this box, your customized translations will be overwritten and replaced by the official ones."
        ),
        'state':
        fields.selection([('init', 'init'), ('done', 'done')],
                         'Status',
                         readonly=True),
    }
    _defaults = {'state': 'init', 'overwrite': False}

    def lang_install(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        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')])
            if language_obj.overwrite:
                context = {'overwrite': True}
            modobj.update_translations(cr, uid, mids, lang, context or {})
            self.write(cr, uid, ids, {'state': 'done'}, context=context)
        return {
            'name': _('Language Pack'),
            'view_type': 'form',
            'view_mode': 'form',
            'view_id': False,
            'res_model': 'base.language.install',
            'domain': [],
            'context': dict(context, active_ids=ids),
            'type': 'ir.actions.act_window',
            'target': 'new',
            'res_id': ids and ids[0] or False,
        }
Exemplo n.º 5
0
class wizard_lang_install(wizard.interface):
    def _lang_install(self, cr, uid, data, context):
        lang = data['form']['lang']
        if lang:
            modobj = pooler.get_pool(cr.dbname).get('ir.module.module')
            mids = modobj.search(cr, uid, [('state', '=', 'installed')])
            modobj.update_translations(cr, uid, mids, lang)
        return {}

    fields_form = {
        'lang': {
            'string': 'Language',
            'type': 'selection',
            'selection': tools.scan_languages(),
        },
    }

    states = {
        'init': {
            'actions': [],
            'result': {
                'type':
                'form',
                'arch':
                view_form,
                'fields':
                fields_form,
                'state': [('end', 'Cancel', 'gtk-cancel'),
                          ('start', 'Start installation', 'gtk-ok', True)]
            }
        },
        'start': {
            'actions': [_lang_install],
            'result': {
                'type': 'form',
                'arch': view_form_end,
                'fields': {},
                'state': [('end', 'Ok', 'gtk-ok', True)]
            }
        },
    }
Exemplo n.º 6
0
class hr_language(orm.Model):
    _name = 'hr.language'
    _columns = {
        'name':
        fields.selection(tools.scan_languages(), 'Language', required=True),
        'description':
        fields.char('Description', size=64, required=True, translate=True),
        'employee_id':
        fields.many2one('hr.employee', 'Employee', required=True),
        'read':
        fields.boolean('Read'),
        'write':
        fields.boolean('Write'),
        'speak':
        fields.boolean('Speak'),
    }

    _defaults = {
        'read': True,
        'write': True,
        'speak': True,
    }
Exemplo n.º 7
0
 def exp_list_lang(self):
     return tools.scan_languages()
Exemplo n.º 8
0
 def exp_list_lang(self):
     return tools.scan_languages()