[IMP] base: UX improvement of Load Languages

The activation of languages was changed at bd3a553ad9
This commit makes a few changes/fixes

- When executing the toggle_active method do not open the wizard but load
directly the language

- Rename the name of the button in tree view, Download was confusing as implies
the resources are downloaded while it is only loaded
- Remove duplicated help

- Add action button to load the language from the form view (as it the only way
from the form view was using the "Unarchive" action)

- Add label directly next to the field (was making a line return)
- Set the placeholder on the field (no effect on the label)
- Remove groups as the view is already restricted to system users

Follow-up of task id 2026150

closes odoo/odoo#34940

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
Martin Trigaux
2019-07-17 10:27:25 +00:00
parent 2e91d26194
commit 1866bd1900
3 changed files with 17 additions and 16 deletions
+4 -10
View File
@@ -215,16 +215,10 @@ class Lang(models.Model):
def toggle_active(self):
super().toggle_active()
# Automatically load translation
if len(self) == 1 and self.active:
return {
'name': "Load a Translation",
'type': 'ir.actions.act_window',
'res_model': 'base.language.install',
'context': {'default_lang': self.code},
'view_mode': 'form',
'target': 'new',
'views': [[False, 'form']],
}
active_lang = [lang.code for lang in self.filtered(lambda l: l.active)]
if active_lang:
mods = self.env['ir.module.module'].search([('state', '=', 'installed')])
mods._update_translations(filter_lang=active_lang)
@api.model_create_multi
def create(self, vals_list):
+10 -1
View File
@@ -13,7 +13,9 @@
<field name="translatable" groups="base.group_no_one"/>
<field name="active"/>
<button name="%(base.action_view_base_language_install)d"
string="Download and Update Translation" type="action" icon="fa-refresh" help="Download and Update Translation"/>
string="Activate Language and Update Translations"
type="action"
icon="fa-refresh"/>
</tree>
</field>
</record>
@@ -23,6 +25,13 @@
<field name="arch" type="xml">
<form string="Languages">
<sheet>
<div class="oe_button_box" name="button_box">
<button string="Activate and Translate"
name="%(base.action_view_base_language_install)d"
type="action"
class="oe_stat_button"
icon="fa-refresh" />
</div>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
+3 -5
View File
@@ -213,18 +213,16 @@
<page string="Preferences">
<group>
<group string="Localization" name="preferences">
<label for="lang" placeholder="System (English)"/>
<field name="active" invisible="1"/>
<label for="lang" />
<div class="o_row">
<field name="lang"/>
<field name="lang" placeholder="System (English)"/>
<button
type="action"
name="%(base.res_lang_act_window)d"
class="btn-sm btn-link mb4 fa fa-globe"
aria-label="More languages"
groups="base.group_system"
title="More languages"
/>
title="More languages"/>
</div>
<field name="tz" widget="timezone_mismatch" options="{'tz_offset_field': 'tz_offset'}" />
<field name="tz_offset" invisible="1"/>