The action "Load a Translation" is wrongfully considered as only for installation of a new language (while it is for update too). The action "Synchronize Terms" is wrongfully considered as to refresh translations of installed language (while it is to generate empty translations). Rename to "Generate Missing Terms" The res.lang tree view encourage this misconception with a "update terms" that actually triggers a synchronize terms action. Change the triggered action to the "Load & Update" Move the list of languages to always visible in settings. This list is not very technical and will avoid to go to debug mode for basic actions like updating the sources of checking what languages are installed. Going less often to dev mode will hide the misleading "Synchronize Terms" action for normal users. Closes #19911
56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models, _
|
|
|
|
|
|
class BaseLanguageInstall(models.TransientModel):
|
|
_name = "base.language.install"
|
|
_description = "Install Language"
|
|
|
|
@api.model
|
|
def _default_language(self):
|
|
""" Display the selected language when using the 'Update Terms' action
|
|
from the language list view
|
|
"""
|
|
if self._context.get('active_model') == 'res.lang':
|
|
lang = self.env['res.lang'].browse(self._context.get('active_id'))
|
|
return lang.code
|
|
return False
|
|
|
|
@api.model
|
|
def _get_languages(self):
|
|
return self.env['res.lang'].get_available()
|
|
|
|
lang = fields.Selection(_get_languages, string='Language', required=True,
|
|
default=_default_language)
|
|
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')],
|
|
string='Status', readonly=True, default='init')
|
|
|
|
@api.multi
|
|
def lang_install(self):
|
|
self.ensure_one()
|
|
mods = self.env['ir.module.module'].search([('state', '=', 'installed')])
|
|
mods.with_context(overwrite=self.overwrite)._update_translations(self.lang)
|
|
self.state = 'done'
|
|
return {
|
|
'name': _('Language Pack'),
|
|
'view_type': 'form',
|
|
'view_mode': 'form',
|
|
'view_id': False,
|
|
'res_model': 'base.language.install',
|
|
'domain': [],
|
|
'context': dict(self._context, active_ids=self.ids),
|
|
'type': 'ir.actions.act_window',
|
|
'target': 'new',
|
|
'res_id': self.id,
|
|
}
|
|
|
|
def reload(self):
|
|
return {
|
|
'type': 'ir.actions.client',
|
|
'tag': 'reload',
|
|
}
|