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>
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# -*- encoding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class BaseLanguageInstall(models.TransientModel):
|
|
|
|
_inherit = "base.language.install"
|
|
|
|
website_ids = fields.Many2many('website', string='Websites to translate')
|
|
|
|
@api.model
|
|
def default_get(self, fields):
|
|
defaults = super(BaseLanguageInstall, self).default_get(fields)
|
|
website_id = self._context.get('params', {}).get('website_id')
|
|
if website_id:
|
|
if 'website_ids' not in defaults:
|
|
defaults['website_ids'] = []
|
|
defaults['website_ids'].append(website_id)
|
|
return defaults
|
|
|
|
def lang_install(self):
|
|
action = super(BaseLanguageInstall, self).lang_install()
|
|
if self.website_ids and self.lang_ids:
|
|
self.website_ids.language_ids |= self.lang_ids
|
|
params = self._context.get('params', {})
|
|
if 'url_return' in params:
|
|
return {
|
|
'url': params['url_return'].replace('[lang]', self.first_lang_id.code),
|
|
'type': 'ir.actions.act_url',
|
|
'target': 'self'
|
|
}
|
|
return action
|