Hidden Performance Killers in Odoo: What Most Developers Don’t Notice

March 10, 2026 by
Hidden Performance Killers in Odoo: What Most Developers Don’t Notice
Alfin Isnain Hariawan
| No comments yet

Performance issues are one of the most common problems in Odoo implementations. Many developers assume that slow performance is caused by server limitations or large datasets. However, in many cases, the real issue lies in how the code is written.  Certain coding patterns in Odoo can silently degrade performance without developers realizing it. These hidden performance killers can significantly slow down the system, especially when the database grows larger.


In this article, we will explore some of the most common hidden performance killers in Odoo and how to avoid them.


1. Using search() Inside Loops

One of the most common mistakes in Odoo development is calling search() repeatedly inside a loop.

Example of problematic code:

for partner in partners:
orders = self.env['sale.order'].search([
('partner_id', '=', partner.id)
])

At first glance, this code seems fine. However, if there are 1,000 partners, this code will execute 1,000 database queries.

This problem is commonly known as the N+1 query problem.

A better approach is to fetch all the records in a single query.

Example improvement:

orders = self.env['sale.order'].search([
('partner_id', 'in', partners.ids)
])

By doing this, Odoo executes only one query instead of thousands.


2. Overusing Computed Fields

Computed fields are powerful, but they can also become a performance bottleneck if used incorrectly.

For example:

total_amount = fields.Float(compute='_compute_total')

If the compute method processes large datasets or complex logic, it will be triggered repeatedly.

This can become problematic when:

  • opening list views
  • generating reports
  • performing searches

A common optimization is to use:

store=True

Stored computed fields are saved in the database, which allows Odoo to avoid recalculating them every time they are accessed.

However, developers must ensure the correct dependencies are defined.


3. Inefficient Use of @api.onchange

The @api.onchange decorator is commonly used to update fields dynamically in forms. However, excessive logic inside onchange methods can slow down the user interface.

Example:

@api.onchange('partner_id')
def _onchange_partner(self):
orders = self.env['sale.order'].search([
('partner_id', '=', self.partner_id.id)
])

If this method performs heavy database operations, every field change in the form can trigger slow responses.

Best practices include:

  • keeping onchange logic lightweight
  • avoiding large database queries
  • moving heavy logic to server-side methods when possible


4. Loading Too Many Records in Views

Another hidden performance issue occurs when views attempt to load too many records.

For example, opening a list view containing hundreds of thousands of records without proper filters.

This can cause:

  • slow loading time
  • heavy memory usage
  • browser lag

To avoid this issue:

  • use domain filters
  • limit records with default filters
  • add search filters
  • avoid unnecessary fields in tree views


5. Ignoring Prefetch Mechanism

Odoo’s ORM includes a prefetching mechanism that automatically loads related records efficiently. However, developers can accidentally break this mechanism.

Example of inefficient code:

for order in orders:
print(order.partner_id.name)

If not handled properly, Odoo may execute additional queries for each partner.

A better approach is to ensure related fields are accessed in batch operations.

Understanding how the ORM prefetch system works can significantly improve performance.


6. Writing Complex Domains Repeatedly

Complex domains that are executed repeatedly can also impact performance.

Example:

self.env['account.move'].search([
('state', '=', 'posted'),
('date', '>=', start_date),
('date', '<=', end_date),
('company_id', '=', company_id)
])

If this query is executed many times within loops or computed fields, it can slow down the system.

Developers should consider caching results or restructuring the logic to reduce repeated database queries.


7. Large Many2many Operations

Many developers underestimate the cost of manipulating large Many2many fields.

For example:

record.tag_ids = [(6, 0, large_list_of_ids)]

If large_list_of_ids contains thousands of records, the operation can be expensive.

Optimizing such operations or batching updates can significantly improve performance.


Conclusion

Performance optimization in Odoo is not only about hardware or database size. In many cases, slow systems are the result of inefficient coding patterns.

Some of the most common hidden performance killers include:

  • repeated database queries inside loops
  • excessive computed fields
  • heavy onchange logic
  • loading too many records in views
  • inefficient use of the ORM

By understanding these patterns and writing optimized code, developers can dramatically improve the performance of their Odoo systems.

Good performance is not achieved by accident—it is the result of careful design and awareness of how Odoo works internally.


Hidden Performance Killers in Odoo: What Most Developers Don’t Notice
Alfin Isnain Hariawan March 10, 2026
Share this post
Archive
Sign in to leave a comment