Enable Dark Mode!
By: Irfan A

How to Transfer Data in Odoo Using XML-RPC

Technical Odoo 13 CRM

Using XML-RPC we can transfer data from one database to another, we can write and delete Odoo records. For example, we are transferring the data from odoo12 to odoo13. For that we need the port that running on odoo12 and Odoo 13, here we transfer the data in the CRM leads from Odoo 12 to Odoo 13,  First you need to import  xmlrpc.client and we need to set the credentials as below:

import xmlrpc.client

url_odoo12 = "http://cybrosys:8069"
db_odoo12 = 'odoo12'
user_name_db_odoo12 ='1'
password_db_odoo12 = '1'
common_1 = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url_odoo12))
model_1 = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url_odoo12))
version_db_odoo12 = common_1.version()

Here in the url_odoo12 variable, you want to specify the link of the database when running Odoo 12, In db_odoo12 we want to specify the database name, and next need to specify the username and password of the database.common is the endpoint provides meta-calls which don’t require authentication. Inside the variable common need to specify the link of the database. the models variable is used to call methods of Odoo models via the execute_kw RPC function, here also we have to specify the database URL. Same like  above next we want to specify the database details of odoo13

url_odoo13 = "http://cybrosys:8089"
db_odoo13 = 'odoo13'
user_name_db_odoo13 ='1'
password_db_odoo13 = '1'
common_2 = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url_odoo13))
model_2 = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url_odoo13))
version_db_odoo13 = common_2.version()

Here we specify the URL of odoo13, database name used for odoo13, and the username and password for the db, then we specify the common, model, and the version. After these, if we print the version_db_odoo12 and   version_db_odoo13, if the data entered having no mistake we can get the print with the service version containing the version. If there is some error we will get an error message.

Next we want to authenticate the credentials:

odoo_12 = common_1.authenticate(db_odoo12, user_name_db_odoo12, password_db_odoo12, {})
odoo_13 = common_2.authenticate(db_odoo13, user_name_db_odoo13,password_db_odoo13, {})

In the odoo_12 variable we want to  pass all information in odoo12,same as that we want to pass odoo_13 details of the odoo13.if the information that passed wrong it will not authenticate while printing the variable you will get it as False.Then we have to fetch the data from odoo12:

model_crm =model_1.execute_kw(db_odoo12, odoo_12, password_db_odoo12,
    'crm.lead', 'search_read',
    [[]],{'fields': ['id','name','email_from']})

Before the data transfer the CRM leads of Odoo 13 is empty:


We want to transfer the below data of Odoo 12 to Odoo 13


So here we have all the data in the odoo12 so next we want to transfer the data:

for line in model_crm:

new_data = model_2.execute_kw(db_odoo13, odoo_13, password_db_odoo13,'crm.lead', 'unlink',[line])

After running the above code  the data will be  transfer from odoo12 to odoo12:


All data in the leads in odoo12 is transferred to Odoo 13. Thus we can transfer data from one version to another using Xmlrpc.

If you need any assistance in odoo, we are online, please chat with us.


Salem Alzubaidi

Transfer Data Between Databases Using XMLRPC In Odoo 15 (same version 15)




Leave a comment




Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message