Get a Sneak-Peak on How to Import Excel File with Python Script in Odoo

Chirag Jogi

Delivery Head

ow to Import Excel File with Python Script in Odoo

In the past two years, Odoo has turned out to be a blessing for different industry verticals. This innovative software suite is used widely to develop everything from an online pharmacy solution to a distinguished banking app.

Odoo is an ideal solution for start-ups, enterprises, and large organizations, as it can transform complex business structures into a simple and organized structure. Additionally, this platform offers a wide range of features that can enhance productivity and streamline operations.

You can use an integrated system to share data across departments with a few clicks seamlessly. Furthermore, Odoo ERP has become the reliable pillar of several businesses. As a result, it has reformed processes for:

  • Inventory management
  • Production
  • Order management
  • Supply chain management, and many more.

Today, talented Odoo ERP development services can offer you customized solutions suitable for your entity.
[Also read: Warehouse Picking made Faster with Odoo Mobile Inventory Application]

In this article, we have discussed the following:

  • Understanding Odoo
  • Steps to Import Excel File with Python Script in Odoo
  • Prominent Odoo Benefits to Shape Future of Your Business

Understanding Odoo

Founded in 2005, Odoo is an open-source software suite for business modules and applications. It was also known as OpenERP and is suitable for several processes such as accounting, CRM, manufacturing, sales, and many more.

Have a Project Idea?

Want to convert your idea into a successful app or website? Schedule your free call with our expert now.

Odoo has gained popularity in a short span due to its open-source capabilities across varied industry verticals. Besides, it is also affordable for businesses of all nature.

Odoo functions on modules that are easy-to-install, allowing users to quickly and easily add or remove functionality based on their specific needs. Moreover, these modules are designed such that they can communicate and share data across departments and systems, thereby enabling seamless integration across different parts of the organization.

It’s worth noting that the open-source Odoo ERP systems offer over 30 main modules and 16,000 third-party apps and plugins in the app store, giving users access to a wide range of features and customizations. As a result, users can easily extend the functionality of their ERP system to meet their specific needs.

With a wide array of plugins, it is convenient for businesses to choose the right module for their company.

A few striking features of Odoo ERP:

  • Advanced and real-time updates
  • User-friendly
  • Global support
  • Smooth third-party integrations
  • Reduced implementation costs
  • Flexibility
  • Readymade apps
  • Advanced modular designs

What are the Steps to Import Excel File with Python Script in Odoo?

Step:1 Select the excel file that you want to import. We have shared here an example in the following image.

Steps to Import Excel File with Python Script in Odoo

[Also read: 8 Reasons Why Odoo Is the Most Secure Platform According to OWASP]

The excel sheet comprises the following columns:

  • Column 1: Name of either the company or customer
  • Column 2: Boolean field column
  • Column 3: Street name
  • Column 4: ZIP code
  • Column 5: City name
  • Column 6: Name of the state
  • Column 7: Name of the Country
Steps to Import Excel File with Python Script in Odoo
Fig 2

Step: 2 To import a file into Odoo, users can create a wizard that facilitates the process. The file name should notify the path and location of the Excel file, as shown in Fig. 2 for a better understanding of the file name.

Step: 3 Once the wizard is created, users can click on the “Import customer” button to execute the Python script. A clear vision of how your Python script looks like is shown in Fig. 3, allowing users to review and edit the script as needed.

Steps to Import Excel File with Python Script in Odoo
Fig 3

In this example, we have used the xlrd library to read the data from the excel file. We have also used try to test errors in a specific block of code and except to manage those errors.

In case you have entered the wrong file name or the file name is not found in the directory it will notify you with a user error- No such file or directory found.

Xlrd.open_workbook- This will open a spreadsheet file for data extraction.

Wb.sheet_by_index(0)- This will help you to open sheets with the help index values. For instance, (0) first sheet from the file, (1) indicates the second sheet from the file, and further so on.

The loop function is used to iterate all the rows. For example, if row>=1, then it is referred to as an if statement. The row index is in range(thesheet.nrows).

We have used vals as a dictionary which also comprises a key and value pair. A section on the left side highlights keys field name. Once this is done, create is called which is an ORM method and then you have to pass it through the vals dictionary.

This is the easiest method to import excel files in Odoo using python script.

What are the Prominent Odoo Benefits to Shape Future of Your Business?

Open Source

Modern Odoo-ERP software offers cutting-edge businesses with automated and streamlined processes, making it easier for companies to manage their operations and stay competitive in today’s fast-paced business environment. This software can convert day-to-day hassles into a synchronized process, which results in increased efficiency, reduced costs, and better overall business performance.

In addition, Odoo empowers companies to lead the market with the right use of the latest technology and adopt industry changes, giving them the ability to stay ahead of the curve and remain relevant in an ever-changing business landscape.

The open-source capability of Odoo ensures that the source code is accessible to everyone, which provides a platform for constant modifications and evaluation.

This means that thousands of developers work round the clock on Odoo ERP to discard bugs, customize, and introduce new features in the most natural form as per business requirements, ensuring that the software remains up-to-date and meets the evolving needs of businesses.

Why Quick and Futuristic Decision-Making Capabilities are Important ?

Odoo offers real-time data to businesses, providing a wealth of information that can be considered to make quick and lucrative business decisions. By accessing up-to-date information about marketing, inventory, accounting, and other business areas, companies can make faster and more informed decisions that can help them save valuable resources and time.

Additionally, with real-time data, businesses can identify trends, patterns, and opportunities in their operations that may not have been visible before. This can help companies to develop more effective strategies, optimize their processes, and gain a competitive advantage in their industry. With the right tools and technology, businesses can harness the power of real-time data to drive growth and success.

Timely decisions can save your business from unwanted losses and skipping deadlines. A responsive vision offers better business potentiality.

Companies with such capabilities can detect flaws in advance and rectify them before they turn into an issue. The integrated detailed reports make it convenient for managers to make robust and quick business decisions.

Easy integration

Odoo is not only customizable but also API-friendly and easy to integrate with. It is easy to implement Odoo ERP and integrate it with your existing systems. This way, your team doesn’t have to experience major behavioral changes.

Instead, they experience better connectivity across systems and departments.

Reduced Implementation Costs

Odoo has a comparatively low cost of implementation and maintenance. Additionally, Odoo has no licensing fees which save you a heavy cost of investment.

Odoo’s Enterprise version has a significant number of features and is inclusive of licensing fees. However, the cost is still lesser than other expensive business solutions.
If you are looking for the right Odoo Partner to take your business to the next-level, contact Brainvire today.

It will Improved Data Transparency and Productivity

When you integrate Odoo ERP with your small enterprise system, you eliminate the probability of errors and enter the same data into the system. The integrated system ensures that each department has proper access to data related to their department.

This eliminates the scope of data duplicity in the business.

Alongside, Odoo ERP eliminates the need for departments to go through a lengthy process to obtain a piece of particular information. With just a few clicks, they can access the required information, which can significantly improve efficiency and streamline operations.

Furthermore, this level of data transparency ensures that there is no need for additional investments in data security and maintenance. The firm can benefit from increased security and reliability of data management without incurring additional expenses.

As a result, your company can use the additional time and resources to improve productivity. Different departments can coordinate among themselves through this integration, plan activities, and complete tasks within the set deadline. This level of collaboration can lead to better decision-making, improved communication, and increased productivity.

Overall, a single system that can overlook all business operations can significantly improve net business productivity, helping companies to remain competitive and thrive in their respective industries.

Highly Customized and Secured Platform

The Odoo-ERP solution is highly-flexible, reliable, and suitable for all companies. Organizations have the liberty to combine functionalities and features suitable for their firm. Developers can assist you to make the right choice in this process.

The open-source nature of this software elevates the security capabilities. Experts can easily find flaws and craft a robust solution that is suitable for your business purpose.

This user-friendly solution can expand your future potential.

Learn more about the Odoo software suite and its impact on your business from experts. Call us now!


How to Automate an Excel Sheet in Python?

To analyze your data in an Excel sheet, you must ensure that the format is XSLX. After that, you need to import pandas and Openpyxl libraries in Python. Once you have done that, you can create a Pivot Table using Pandas and export it in the exact location as your Python scripts.

To design the reports using Openpyxl with the Barchart and Reference Modules, you can automate the report with Python by writing all the code into one function to make it easier. This approach can significantly reduce the time and effort required to generate the reports, which can be especially useful when dealing with large data sets.

How to delete one or more rows in excel using Openpyxl?

Openpyxl is a library in Python that can be used for XLSX/XLSM/XLTX/XLTM files. Import the library for deleting one or more rows in excel using Openpyxl. Load the excel file with Openpyxl and load the sheet from it. Use the function “ws.delete_rows(firstrow, numberofrows)”. To delete multiple rows, tweak the function to “we.delete_rows(1, ws.max_row+1).

How to Import an Excel File into Python using Pandas?

To start with the process of importing an Excel file, you should first install PIP libraries for Pandas and XLRD. After that, you need to capture the entire file path of the excel file on your computer.

Next, you can apply the “pandas.read_excel(r’path of your excel file)” function to read the Excel file. It is important to note that you should place an “r” before the path string to address special characters.

Once you have completed these steps, you can run the code to import the Excel file using this location. This approach can help you to import Excel files in a more efficient and accurate manner, which can be particularly useful when working with large data sets.

How do I merge Excel files into one workbook in Python?

When it comes to merging Excel files using Python with Pandas, the process is relatively straightforward. First, you need to install the Pandas module with PIP.

Next, you can use the “dataframe.append()” function to merge fewer Excel files with less data. However, for more extensive data and files, it is recommended to use the “pandas.concat()” function. This function is particularly useful when you need to merge large data sets from multiple Excel files.

By following these steps, you can quickly and easily merge Excel files using Python with Pandas. This can save you a lot of time and effort, especially when working with large data sets that need to be consolidated for further analysis or reporting.

How do you plot data in Excel using Python?

Use the command prompt to import the PIP Pandas and Matplotlib modules. Matplotlib helps in plotting, while Pandas is used to handle the data in Excel. Load the data using the “read_excel” function. Separate the X and Y coordinates. Then, make a scatter plot with the command “plt.plot(x,y)”.

About Chirag Jogi

Chirag has worked with companies of all sizes, helping them use Odoo ERP to its fullest potential. With his expertise in Odoo ERP and years of experience working as a consultant, there isn’t anything that he cannot do for your company. He can help you take full advantage of this powerful tool so you can boost your business growth. To catch up on Odoo ERP and its impact on your business, connect with Chirag today.

Lets Connect!