Source code for odoo_xmlrpc_twisted.functions.get_installed_languages

"""
The Module gives back all installed languages of the Odoo system.
"""

# call the function "get_settings_odoo" to get the parameters
# for the logging of the model on the "odoo Webservice API"
try:
    from .get_settings_odoo import get_settings_odoo
except ImportError:
    from get_settings_odoo import get_settings_odoo
result   = get_settings_odoo()
db       = result[0]
uid      = result[1]
password = result[3]
models   = result[4] 


[docs] def get_installed_languages(): """ Get the installed languages from Odoo system by getting it from the 'res.lang' model. Result is an array with the language names and the codes. """ # Call the 'execute_kw' method to search for installed languages languages = models.execute_kw(db, uid, password, 'res.lang', 'search_read', [[]], # Domain, empty to fetch all installed languages {'fields': ['name', 'code']}) # Fields to fetch # prepare the name of each language to a simple form # result should be like: [{'id': 1, 'name': 'English', 'code': 'en_US'}] for item in languages: language_name = item['name'] if '/' in language_name: # example: 'German / Deutsch' comes to 'Deutsch' simple_name = language_name.split(" ")[2] else: # example: 'English (US)' comes to 'English' simple_name = language_name.split(" ")[0] item['name'] = simple_name return(languages)