Purpose ======= Add "Activate" button when selecting multiple languages, select multiple languages when clicking on "Add languages" in settings. Specifications ============= `lang` variable in `base.language.install` changed from Selection to Many2many to allow multiple languages being activated at once. Hide globe icon for language fields from view mode (only visible when editing). Remove state in base.language.install since it's no longer need to keep track of the installation step. Task-2662548 closes odoo/odoo#78287 Related: odoo/upgrade#2921 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, models, tools, _
|
|
from odoo.exceptions import UserError
|
|
from odoo.http import request
|
|
|
|
|
|
class Lang(models.Model):
|
|
_inherit = "res.lang"
|
|
|
|
def write(self, vals):
|
|
if 'active' in vals and not vals['active']:
|
|
if self.env['website'].search([('language_ids', 'in', self._ids)]):
|
|
raise UserError(_("Cannot deactivate a language that is currently used on a website."))
|
|
return super(Lang, self).write(vals)
|
|
|
|
@api.model
|
|
@tools.ormcache_context(keys=("website_id",))
|
|
def get_available(self):
|
|
if request and getattr(request, 'is_frontend', True):
|
|
return self.env['website'].get_current_website().language_ids.get_sorted()
|
|
return super().get_available()
|
|
|
|
def action_activate_langs(self):
|
|
"""
|
|
Open wizard to install language(s), so user can select the website(s)
|
|
to translate in that language.
|
|
"""
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'name': _('Add languages'),
|
|
'view_mode': 'form',
|
|
'res_model': 'base.language.install',
|
|
'views': [[False, 'form']],
|
|
'target': 'new',
|
|
}
|