[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:
committed by
Yannick Tivisse
parent
8f137f66bc
commit
410abecd24
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user