Odoo's greatest strength begins where the ready-made modules end. With Python + XML, it's possible to add company-specific business rules into the system and run them within the standard Odoo interface. In this article we'll cover the steps of custom module development, its best practices and deployment strategies.
01. Module Anatomy
An Odoo module's folder structure:
- manifest.py (metadata)
- models/ (Python business rules)
- views/ (XML interface definitions)
- security/ (access rules)
- data/ (default records)
- static/ (icon, css, js)
A short module works with 50-100 lines of code.
02. Model Definition and Inheritance
Odoo's ORM (Object-Relational Mapper) maps the database to Python classes. To define a new model: class MyModel(models.Model): _name = "my.model"; and the fields are defined. To add a field to an existing model, _inherit is used.
03. Defining Views
Forms, lists and search filters are defined with XML. With the inherit_id attribute it's possible to add a field to an existing Odoo form; where it's placed is specified with xpath expressions.
04. Studio vs Code
Simple changes (adding a new field, modifying a form) can be done with Studio without writing code. But for complex business rules, automatic calculations or external API integration, writing Python code is required. Code-based modules are more maintenance-friendly than Studio.
05. Deployment and Version Control
Custom modules should be versioned in Git. odoo.sh is a platform that automatically builds your own Git repository. In self-hosted installations, deployment is automated with CI/CD pipelines.