Odoo Migration Options - Master Data and Transactional Data
top of page
  • Writer's pictureTek Siong, Hock

Odoo Migration Options - Master Data and Transactional Data


1) Master Data - Standard Odoo Import Function via the Ms Excel.

You may import master data like Chart of Account, Customer or Vendor, Product, UoM, Product Category, etc.



Download the Import Template. For any field that is missing, just add the label of the field in the column.



2) Transactional Data - Complex Data (multiple lines) from the Legacy System.

If you need to import historical Journal Entries, Invoices, Sales Order, etc into the Odoo and able to extract the legacy data into the Excel format, the easiest way is to write and run a python script with XML-RPC and xlrd to update the remote database. In the script, you can not only do the validation, but also create some related data object on the fly.


a) Connecting to the remote database.

dbname = "db_name"
username = "username@gmail.com"
pwd = "mypassword"
server = "http://IP:8069"

sock_common = xmlrpc.client.ServerProxy(server + "/xmlrpc/common")
sock = xmlrpc.client.ServerProxy(server + "/xmlrpc/object")
uid = sock_common.login(dbname, username, pwd)

b) Read the Excel from the column 0, 1, 2, 3, and so on.


xlrd.xlsx.ensure_elementtree_imported(False, None)
xlrd.xlsx.Element_has_iter = True
workbook = xlrd.open_workbook("Migration.xlsx")
worksheet = workbook.sheet_by_name('sheet1')
num_rows = worksheet.nrows - 1
num_cells = worksheet.ncols - 1
curr_row = 0  # Update curr_Row to 0

while curr_row < num_rows:
    curr_row += 1
    row = worksheet.row(curr_row)
    if row[1].value:
    sequence_str = re.sub(r"^\s+|\s+$", "", str(row[1].value))

c) Update the data from the excel to the dictionary, and finally create as new record in the database.

data = {}
data.update({"sequence": sequence_str})
my_model = sock.execute(
    dbname, uid, pwd, "my.model", "create", data
)
159 views0 comments
bottom of page