Search code examples
pythonodooxml-rpcodoo-10

Alter Odoo XmlRPC context to use a specific language


I need to get the translated data from odoo with a specific language using XMLRPC by default odoo sends data in the default language which is English

api.execute_kw(db, uid, pwd, 'res.country', 'search_read', [[]], {'fields': ['name']})

how to add context to this request to use a specific translation language.


Solution

  • let's say the endpoint is api you just need to add the param context as shown in the following code

    api.execute_kw(db, uid, pwd, 'res.country', 'search_read', [[]], {'fields': ['id', 'name'], 'context' :{'lang': "fr_FR"}})