Enable Dark Mode!
how-to-transfer-data-from-odoo-14-to-odoo-15-using-xml-rpc.jpg
By: Aswathi PN

How to Transfer Data From Odoo 14 to Odoo 15 Using XML-RPC

Technical Odoo 15

We can transfer the data from one database to another, one of the methods used for data transfer is using XML-RPC. We can update, and write records. For example, we transfer data from Odoo 14 to Odoo 15. For that, we have two opened odoo portals, one portal in Odoo 14 and another one in Odoo15. Here I am transferring Leads on the CRM models on Odoo 14 to Odoo 15.                                                                                                                  

The first step is to import the XML-RPC for that we can use the below code

import xmlrpc.client

Next, we have to define some variables to store the credentials

url_db1 = "http://127.0.0.1:8044"
db_1 = 'odoo14_com'
username_db_1 = 'name'
password_db_1 = 'name'
common_1 = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url_db1))models_1 = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object.format(url_db1))version_db1 = common_1.version()

url_db1 - is the variable that assigns the URL of the Odoo 14 which is  the database to  transfer data

db_1 - is the variable to store the database name from which database to transfer the data.

username_db_1 - is to store the user name of the database

password_db_1 - is to store the password of the database

common_1 - the common is not required for authentication or validations, inside this variable we can specify the link of the Odoo14 database.

models_1 - 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

version_db1 - we can get the details of the database

url_db2 = "http://localhost:8065"
db_2 = 'odoo15_community'
username_db_2 = 'name'
password_db_2 = 'name'
common_2 = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url_db2))
models_2 = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object.format(url_db2))
version_db2 = common_2.version()

url_db2  is the URL of the Odoo15 database, db_2  is the Odoo15 database, username_db_2 is the variable to store the username of the Odoo15 database, respectively the password_db_2 shows the password of that same database.and also the common_2 and models_2 has the same feature of common_1 and models_1 that we discussed above

The next step is to validate the credentials

uid_db1 = common_1.authenticate(db_1, username_db_1, password_db_1, {})
uid_db2 = common_2.authenticate(db_2, username_db_2, password_db_2, {})

In the uid_db1 variable, we can pass all information from the Odoo14 database, same as that we can pass uid_db2 details of the Odoo 15 database. any of the information that we passed is wrong it will not be validated while printing the variable we get it as False. If all the information is correctly passed we can get the correct output.

Then we can fetch all the information from  Odoo14

db_1_leads = models_1.execute_kw(db_1, uid_db1, password_db_1, 'crm.lead', 'search_read', [[]], {'fields': ['id', 'name', 'email_from']})

Before fetching the data the leads page of the odoo15 CRM is blank

how-to-transfer-data-from-odoo-14-to-odoo-15-version-cybrosys

We want to transfer data from Odoo14 to Odoo15

how-to-transfer-data-from-odoo-14-to-odoo-15-version-cybrosys

Here we can see the pipeline view of the leads on the Odoo14 database.

new_lead = models_2.execute_kw(db_2, uid_db2, password_db_2, 'crm.lead', 'create', [db_1_leads])

After running this code go to the CRM leads and refresh the page we can see that the all leads from the Odoo14 will be visible on the Odoo15 leads view

how-to-transfer-data-from-odoo-14-to-odoo-15-version-cybrosys

All data on the Odoo14 will be transferred to the Odoo15 database that we can see here. Here we discussed the data transfer via XMLRPC This is one of the methods to transfer data from one version to another.


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



1
Comments

Nivas

How to transfer all the data from sale order odoo14 to odoo15 including attachment data.?

04/03/2024

-

11:35AM



Leave a comment



whatsapp_icon
location

Calicut

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

location

Kochi

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

location

Bangalore

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

Send Us A Message