Writing Inside a Loop
Calling write() on individual records inside a loop generates N SQL queries. Updating 10,000 records takes 30 seconds instead of less than 1 second.
Odoo anti-patterns · Technical reference
The mistakes that pass code review and surface as performance incidents in production.
27 entries · free, no sign-up
Showing all 27 entries
Calling write() on individual records inside a loop generates N SQL queries. Updating 10,000 records takes 30 seconds instead of less than 1 second.
Fetching ALL records into memory then filtering in Python instead of the DB. High memory usage and slow response time on large tables.
Forgetting to call super() breaks the inheritance chain and other installed modules. Features from other modules silently stop working, leading to data corruption.
Assuming a recordset contains only one record without explicitly checking. Silent errors where logic is applied to the first record of a set, ignoring others.
Referencing records by their external ID string instead of using references. Code breaks if the external ID changes or the module is renamed.
Forgetting a dependency or including a field that doesn't trigger recalculation. The compute field doesn't update when the data changes, showing stale info.
Building raw SQL queries with string formatting instead of parameters. Total database compromise via SQL Injection. Sensitive data theft.
Using sudo() to bypass errors instead of fixing underlying access rights. Data leaks: Normal users seeing or modifying data they shouldn't access.
Defining web routes with auth='none' or auth='public' without internal checks. Anonymous users can trigger internal Python methods or view private data.
Saving passwords or API keys in regular Char fields instead of encrypted fields. If the DB is compromised, all third-party integration keys are exposed.
Using xpath position='replace' on standard views. Breaks other modules that try to xpath into the same elements.
Performing complex Python calls inside QWeb XML templates. Slow page rendering because logic runs for every line in a report/view.
Directly manipulating the DOM with jQuery instead of OWL's reactive state. UI becomes out of sync with the component state, causing random bugs.
Designing views that only look good on 1920x1080 screens. The mobile app and tablet views become unusable for on-site staff.
Relying on Odoo to auto-format technical field names as labels. The UI shows 'X_partner_id' instead of 'Customer Name', looking unprofessional.
Accessing relational fields in a loop without prefetching. Extremely slow form loads and list views (100+ queries per page).
Placing heavy business logic in UI-only onchange methods. The UI 'freezes' while typing because the server is processing complex data.
Frequently searched fields without index=True. Full table scans: Odoo gets slower as the DB grows.
Storing 10MB+ PDFs/Images directly in the SQL table. Slow DB backups and high memory usage. Use the filestore instead.
Running heavy data processing every 1 minute. Database lock contention and slow performance for all users.
Running single-threaded in production. One slow user blocks every other user from using Odoo.
Restoring DB without /var/lib/odoo/filestore/. All images, PDFs, and attachments are lost forever.
Exposing Odoo directly to the internet without Nginx. No SSL, no rate limits, no buffer.
Launching a new ERP system before the weekend when support staff is unavailable.
Assuming the 'Consultant' tested everything without involving the actual business users.
Trying to move 10 years of messy history into Odoo in one day without a pilot run.
Giving users a 200-page PDF and expecting them to learn Odoo. They won't read it.
Next
We run technical assessment for Odoo hires, and we take on the work these questions describe.