[IMP] base: Load translation when language is activated

Purpose
=======
Settings > Translations > Languages > I find the language I want
and I click on stat button to activate it.
Now I set it up on my user, it still doesn't work > the langage has not been loaded !!!

Specification
=============
When activating a language load the translation (and open the load translation wizard)
This commit is contained in:
Lucas Lefèvre
2019-07-16 17:28:52 +02:00
committed by Yannick Tivisse
parent 8f137f66bc
commit 410abecd24
+14
View File
@@ -212,6 +212,20 @@ class Lang(models.Model):
langs = self.with_context(active_test=True).search([])
return sorted([(lang.code, lang.name) for lang in langs], key=itemgetter(1))
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']],
}
@api.model_create_multi
def create(self, vals_list):
self.clear_caches()