en

Odoo: How to create load balancing using Locust

February 13, 2023

Tags: Technologies

odoo

 

For any company it is important to have software that helps it manage internal and external administrative processes, such as managing the supply chain in the food industry, for this there are ERPs and perhaps the most robust, functional and versatile of these be Odoo.

 

ERP stands for Enterprise Resource Planning and refers to the software that manages day-to-day business activities. It integrates supply chain, services, purchasing, accounting, human resources and financial processes, all in one system to unify business operations.

 

Odoo is one of these software, recognized for being configured with different modules that allow the user the integral management of a company, covering all essential areas such as: payroll, accounting, sales and customer service. It can be implemented in any type of industries without problems.

 

 

odoo

 

Odoo as CRM and its functions

 

Odoo is also characterized by having CRM, or Customer Relationship Management, functions, which refers to a technological tool designed to manage and collect important information and data about a company's contacts, customers, and potential customers.

 

This is an essential tool for any sales team that wants to stay competitive and grow the company, so Odoo has important and effective CRM features that will contribute to this goal. Among the most important functions are:

 

  • Odoo ERP, with its CRM module, allows users to schedule meetings or calls and create tasks with just one click.
  • Displays an overview of team meetings and activities, allowing you to efficiently coordinate the entire workflow.
  • Users can even make calls to their clients from the same Odoo software platform.
  • If your company's sales agent spots a business opportunity in Odoo CRM, you can quickly send emails to the potential customer.
  • Record a history with all communications between the company and the client.

 

 

odoo

 

Create load balance using Odoo and Locust

 

In their official documentation, they define Locust as “an easy-to-use, programmable, and scalable performance testing tool. You define the behavior of your users in normal Python code, rather than being stuck in a restrictive domain-specific language or user interface. This makes Locust infinitely expandable and very developer friendly.”

 

To install Locust, Odoo Locust and other dependencies

 

pip install locust OdooLocust odoo-client-lib

 

After this, we are going to start creating the Odoo Locust load test

 

Create a python file and put the below code in it. Here we are going to perform a load test using the OdooLocustUser class.

 

from locust import task, between
from OdooLocust.OdooLocustUser import OdooLocustUser
class Seller(OdooLocustUser):
     wait_time = between(0.1, 10)
     host = '127.0.0.1'
     database="database_name"
     login = "login"
     password="password"
     port = port
     protocol="jsonrpc"
     @task(10)
     def read_partners(self):
         customer_model = self.client.get_model('res.partner')
         customer_ids = cust_model.search([])
         customers = cust_model.read(cust_ids)
     @task(5)
     def read_products(self):
         product_model = self.client.get_model('product.product')
         ids = prod_model.search([])
         products = prod_model.read(ids)

 

Run load test

 

After the previous step, the Python file should be executed:

 

locust -f file_name.py

 

While running the above command, we get some details about which port will be executed as below.

 

odoo

 

After this, in any web browser you have accessible go to 127.0.0.1:8089 and the Locust UI will be displayed.

 

odoo

 

In the interface, Locust needs three inputs to start Odoo:

 

1. Number of users.
2. Generation rate: users started per second.
3. Host: if we specify the host in the Python code, it will automatically be filled in here; otherwise we can also add from the UI.

 

With all this data entered, the load test will look like this:

 

odoo

 

And in this simple and fast way, it is possible to perform a load test with Odoo databases using Locust.

 

At Rootstack we are official Odoo partners, so we have the most experienced staff to work with this type of platform and give your company the ERP and CRM solution it needs. Do you have questions about how Odoo CRM works? Do not hesitate to contact us.

 

We recommend you on video