I know how to add translations to my custom module (with .po-files in \i18n-folder). I also know how to force Odoo.sh
to automatically update my custom module during build, with updating the version-number.
This works fine for data, views, and so on. But is doesn't seem to work for my translations. I always have to go to Developer-mode -> Settings -> Translations -> Activate/update.
How can I also automate the update of my translations?
EDIT: I've found the post_init_hook, and tried the following:
# coding: utf-8
from odoo import api, fields, models, _, SUPERUSER_ID
def install_languages(cr, registry):
""" Post init function """
env = api.Environment(cr, SUPERUSER_ID, {})
# install DE language
lang_de = env['base.language.install'].create({'lang': 'de_DE', 'overwrite': False})
env['base.language.install'].lang_install(lang_de)
The line env['base.language.install'].create({'lang': 'de_DE', 'overwrite': False})
however, generates a build-warning with Transient module states were reset
, and then a build-error occurs Failed to load registry
and Failed to load database...
.
EDIT 2: the error had another cause and is fixed. the post_init gives no error, but also does not update the language.