5 best practices for developing Odoo modules
Clean code that survives migrations: conventions, tests and structure for maintainable, long-lived Odoo modules.
A custom module can be your best ally or a technical debt that haunts you with every upgrade. The difference lies in following Odoo's conventions and Python best practices.
1. Respect the standard structure
Every module should have a predictable structure: models/, views/, security/, data/, tests/ and a clear __manifest__.py. Consistency lowers maintenance cost.
2. Inherit, don't rewrite
Leverage Odoo's inheritance model instead of duplicating core logic. That way your module keeps working as Odoo evolves.
from odoo import models, fields, api
class SaleOrder(models.Model):
_inherit = "sale.order"
margin_pct = fields.Float(
string="Margin %",
compute="_compute_margin_pct",
store=True,
)
@api.depends("amount_total", "margin")
def _compute_margin_pct(self):
for order in self:
order.margin_pct = (
(order.margin / order.amount_total) * 100
if order.amount_total else 0.0
)
3. Define security from the start
Don't leave permissions for last. Declare ir.model.access.csv and the necessary record rules as soon as you create a new model.
4. Write tests
Odoo ships with an excellent testing framework. A few tests on critical logic will save you hours of debugging and make migrations far safer.
5. Document and version
A good README, clear commit messages and semantic versioning of the module mean anyone —including your future self— can maintain it.
Conclusion
Developing for Odoo isn't just about "working today", but about still working after the next migration. These five practices make the difference between an asset and a liability.
Comments (0)
Be the first to comment.
Sign in to leave a comment.
Sign inComments are reviewed before publishing.
Related articles
Verifactu, TicketBAI and SII: differences and which applies to you
Three rules that are often confused. We explain what each is, who it applies to, and how they coexist in your Odoo.
How much does it cost to implement Odoo in 2026?
Licences, implementation, development and maintenance: we break down the real cost lines of an Odoo project so you can budget without surprises.
Mandatory e-invoicing in Spain: get your Odoo ready
B2B e-invoicing will become mandatory under Spain's Crea y Crece law. Here's what changes and how to prepare your Odoo.