how to load a translation with jsonrpc(python lib odoorpc) ?
thanks !
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
how to load a translation with jsonrpc(python lib odoorpc) ?
thanks !
Hi,
Try like following
from odoorpc import ODOO
# Connect to the Odoo server
odoo = ODOO('localhost', port=8069)
db_name = 'your_database'
user = 'your_username'
password = 'your_password'
odoo.login(db_name, user, password)
# Get the JSON-RPC client from the ODOO instance
jsonrpc = odoo.jsonrpc
# Load the translation module
module_name = 'base' # Replace with the module name you want to load translations for
jsonrpc.load_module(module_name)
# Logout from
In the above code, you first establish a connection to the Odoo server using the ODOO class from the odoorpc library. Then, you log in to the Odoo server using the login method with your database name, username, and password.
Next, you retrieve the JSON-RPC client object from the odoo instance. The jsonrpc object allows you to perform JSON-RPC requests to the Odoo server.
To load the translation module, you use the load_module method of the jsonrpc client and provide the name of the module you want to load translations for. In the example, 'base' is used as an example module name. Replace it with the actual module name you want to load translations for.
Finally, you log out from the Odoo server using the logout method to close the session.
Remember to replace 'localhost', 8069, 'your_database', 'your_username', and 'your_password' with the appropriate values for your Odoo server configuration
Regards
To load a translation using JSON-RPC in the Python library odoorpc, you can use the execute_kw method to call the load_module_translation method of the ir.module.module model in Odoo.
from odoorpc import ODOO
# Establish a connection to the Odoo server
odoo = ODOO(host='your-odoo-host', port=8069)
db_name = 'your-database-name'
user = 'your-username'
password = 'your-password'
odoo.login(database=db_name, login=user, password=password)
# Specify the module name for which you want to load the translation
module_name = 'your-module-name'
# Call the load_module_translation method to load the translation
module_obj = odoo.env['ir.module.module']
result = module_obj.execute_kw('load_module_translation', [module_name])
# Check the result of the translation loading operation
if result:
print('Translation loaded successfully.')
else:
print('Translation loading failed.')
# Logout from the Odoo server
odoo.logout()
Note: Ensure that you have the odoorpc library installed in your Python environment before running the code. You can install it using pip: pip install odoorpc.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
3
Nov 21
|
5279 | ||
Part of Odoo not translated
Solved
|
|
2
Mar 15
|
5546 | |
|
1
Apr 25
|
150 | ||
|
0
Feb 25
|
496 | ||
|
0
Jan 21
|
2916 |