Source code for odoo_xmlrpc_twisted.functions.get_language

"""
Get the language of a user.
"""

# 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_language(partner_id): """ Function gets the language of a user from odoo table 'res_partner'. """ target_language = 'en_US' # default value if partner_id != '': lang_data = models.execute_kw(db,uid, password, 'res.partner', 'search_read', [[['id', '=', partner_id]]], {'fields': ['lang']}) # if the array is not empty # get the value for 'lang' if lang_data: for key, value in list(lang_data[0].items()): if key == "lang": target_language = value return(target_language)