From 4cdc1f4df2e01604ece0bdf85abd8753b54acfe9 Mon Sep 17 00:00:00 2001
From: Martin Trigaux <mat@odoo.com>
Date: Wed, 11 Oct 2017 09:47:16 +0200
Subject: [PATCH] [FIX] base: avoid confusion between synchronize and update
 terms

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
---
 .../base/module/wizard/base_language_install.py     | 13 ++++++++++++-
 .../base/module/wizard/base_update_translations.py  | 11 ++---------
 .../module/wizard/base_update_translations_view.xml |  8 ++++----
 odoo/addons/base/res/res_lang_view.xml              |  4 ++--
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/odoo/addons/base/module/wizard/base_language_install.py b/odoo/addons/base/module/wizard/base_language_install.py
index ae08af375876..438803ee3880 100644
--- a/odoo/addons/base/module/wizard/base_language_install.py
+++ b/odoo/addons/base/module/wizard/base_language_install.py
@@ -8,11 +8,22 @@ 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)
+    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')],
diff --git a/odoo/addons/base/module/wizard/base_update_translations.py b/odoo/addons/base/module/wizard/base_update_translations.py
index 8f487dbbafe2..f9c9c0c85553 100644
--- a/odoo/addons/base/module/wizard/base_update_translations.py
+++ b/odoo/addons/base/module/wizard/base_update_translations.py
@@ -16,15 +16,8 @@ class BaseUpdateTranslations(models.TransientModel):
         langs = self.env['res.lang'].search([('active', '=', True), ('translatable', '=', True)])
         return [(lang.code, lang.name) for lang in langs]
 
-    @api.model
-    def _default_language(self):
-        if self._context.get('active_model') == 'res.lang':
-            lang = self.env['res.lang'].browse(self._context.get('active_id'))
-            return lang.code
-        return False
-
-    lang = fields.Selection(_get_languages, 'Language', required=True,
-                            default=_default_language)
+
+    lang = fields.Selection(_get_languages, 'Language', required=True)
 
     @api.model
     def _get_lang_name(self, lang_code):
diff --git a/odoo/addons/base/module/wizard/base_update_translations_view.xml b/odoo/addons/base/module/wizard/base_update_translations_view.xml
index cc127b39d1cc..42baf0b04af0 100644
--- a/odoo/addons/base/module/wizard/base_update_translations_view.xml
+++ b/odoo/addons/base/module/wizard/base_update_translations_view.xml
@@ -2,11 +2,11 @@
 <odoo>
     <data>
          <record id="wizard_update_translations" model="ir.ui.view">
-            <field name="name">Synchronize Terms</field>
+            <field name="name">Generate Missing Terms</field>
             <field name="model">base.update.translations</field>
             <field name="arch" type="xml">
-                <form string="Synchronize Terms">
-                    <group string="Synchronize Translation">
+                <form string="Generate Missing Terms">
+                    <group string="Generate Missing Terms">
                         <field name="lang"/>
                     </group>
                     <footer>
@@ -17,7 +17,7 @@
             </field>
         </record>
         <record id="action_wizard_update_translations" model="ir.actions.act_window">
-            <field name="name">Synchronize Terms</field>
+            <field name="name">Generate Missing Terms</field>
             <field name="type">ir.actions.act_window</field>
             <field name="res_model">base.update.translations</field>
             <field name="view_type">form</field>
diff --git a/odoo/addons/base/res/res_lang_view.xml b/odoo/addons/base/res/res_lang_view.xml
index da154ac5ccd3..6e8eed8d4af4 100644
--- a/odoo/addons/base/res/res_lang_view.xml
+++ b/odoo/addons/base/res/res_lang_view.xml
@@ -12,7 +12,7 @@
                     <field name="direction"/>
                     <field name="translatable"/>
                     <field name="active"/>
-                    <button name="%(base.action_wizard_update_translations)d"
+                    <button name="%(base.action_view_base_language_install)d"
                     string="Update Terms" type="action" icon="fa-refresh" help="Update Language Terms"
                     attrs="{'invisible': [('active', '=', False)]}"/>
                 </tree>
@@ -102,6 +102,6 @@
             <field name="context">{'active_test': False}</field>
             <field name="search_view_id" ref="res_lang_search"/>
         </record>
-        <menuitem action="res_lang_act_window" id="menu_res_lang_act_window" parent="menu_translation" groups="base.group_no_one" sequence="1"/>
+        <menuitem action="res_lang_act_window" id="menu_res_lang_act_window" parent="menu_translation" sequence="1"/>
     </data>
 </odoo>
-- 
GitLab