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_odooimportget_settings_odooexceptImportError:fromget_settings_odooimportget_settings_odooresult=get_settings_odoo()db=result[0]uid=result[1]password=result[3]models=result[4]
[docs]defget_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 languageslanguages=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'}]foriteminlanguages:language_name=item['name']if'/'inlanguage_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_namereturn(languages)