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

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

Technical Odoo 15 Odoo 16

To enable communication between various systems or applications, Odoo (formerly known as OpenERP) uses the XML-RPC (Remote Procedure Call) protocol. It enables you to remotely execute methods and retrieve data from an Odoo instance using XML as the transport format.

An external system can communicate with an Odoo server via the web service API that XML-RPC offers. This API allows you to perform various operations, such as creating or updating records, querying data, executing business logic, and more.

To use XML-RPC in Odoo, you typically need to set up the XML-RPC interface on the server-side and then establish a connection from the client-side to interact with the Odoo server. The database name, the URL of the Odoo server, and proper login information such as username and password are required for the connection.

Once the connection is established, the client application can make XML-RPC calls to perform various operations, such as retrieving records, creating new records, updating existing records, executing server-side methods, and more. The XML-RPC calls are encoded in XML format and sent to the Odoo server over HTTP(S).

We can move data from one database to another using a variety of techniques, including XML-RPC. Records can be updated and written. As an illustration, we move data from Odoo 15 to Odoo 16. For that, two Odoo portals—one in Odoo 15 and another in Odoo 16—are open. In this instance, I'm moving Orders from the Sales models in Odoo 15 to Odoo 16.

Importing XML-RPC is the first step, and to do so, use the following code

import xmlrpc.client

In order to store the credentials, we must next declare some variables.

url_db1 = "http://127.0.0.1:8015"
db_1 = 'odoo15_demo'
username_db_1 = admin
password_db_1 = admin
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()

The variable called "url_db1" specifies the database's URL, which is used to transfer data in Odoo 15.

The name of the database from which the data will be copied is stored in the variable db_1.

The variables username_db_1 and password_db_1 contain the username and password for the database. Since the common variable is not needed for authentication or validation, the link to the Odoo15 database can be specified in this variable.

The models_1 - models variable is used to call methods of Odoo models through the execute_kw RPC function. The database URL is also required here.

version_db1: We may access the database's information.

url_db2 = "http://localhost:8065"
db_2 = 'odoo16_demo'
username_db_2 = admin
password_db_2 = admin
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()

The username_db_2 variable stores the username of the Odoo16 database, while the password_db_2 variable displays the password of the same database. url_db2 is the URL of the Odoo16 database, db_2 is the Odoo16 database, and so on.Additionally, the common_2 and models_2 share the same characteristic as the common_1 and models_1 that we previously described.

The verification of credentials is the next step.

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, {})

We may pass all of the details from the Odoo 15 database in the uid_db1 variable, just as we can pass the details from the Odoo 16 database in the uid_db2 variable. When printing the variable, we receive False if any of the information we gave is incorrect because it will not be validated. We can receive the right output if all the information is accurately given.

Then, we can retrieve all the data from Odoo15.

db_1_leads = models_1.execute_kw(db_1, uid_db1, password_db_1, 'sale.order', 'search_read', [], {'fields': ['name', 'partner_id','user_id','amount_total']})

The order page of the Odoo15 Sales is blank before to obtaining the data.

how-to-transfer-data-from-odoo-15-to-odoo-16-using-xml-rpc-1-cybrosys

Data transfer from Odoo15 to Odoo16 is what we're after.

how-to-transfer-data-from-odoo-15-to-odoo-16-using-xml-rpc-2-cybrosys

The pipeline view of the orders on the Odoo15 database is shown.

new_sale = models_1.execute_kw(db_1, uid_db1, password_db_1, 'sale.order',
                                'create',
                                [{'name': rec['name'],
                                  'partner_id': rec['partner_id'][0],
                                  'user_id':rec['user_id'][0],
                                  'amount_total':rec['amount_total']
                                  }])

After running this code go to the Sale order and refresh the page we can see that the all leads from the Odoo15 will be visible on the Odoo16 Sale Order View

how-to-transfer-data-from-odoo-15-to-odoo-16-using-xml-rpc-3-cybrosys

All data on the Odoo15 will be transferred to the Odoo16 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.

To read more about to transfer data from Odoo 14 to Odoo 15, refer to our blog How to Transfer Data From Odoo 14 to Odoo 15 Using XML-RPC


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



0
Comments



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