Extending an Existing Odoo Model

To change what an existing kind of record holds or does, a developer extends the model.

A developer often needs an existing kind of record to hold something more, or do something more. Extending the model is how. This piece is about extending an existing Odoo model.

The need to extend a model

Much Odoo development is not defining new models but changing existing ones. A developer often needs an existing model, an existing kind of record that Odoo, or another module, already provides, a customer, an order, to be extended: to hold an additional field, to have additional or adjusted logic. The customer record should hold an extra piece of information; the order should do something more when it is confirmed. Extending the existing model is how those needs are met.

Extend, do not redefine

The principle for extending an existing model is the central principle of clean Odoo development: extend, do not replace. To make the existing model hold more or do more, the developer extends it, through model inheritance, adding the genuine new field or the genuine new logic, while the existing model otherwise stays exactly as it is. The developer does not take the existing model and redefine it wholly; the developer extends it, the addition a clean layer, the existing model intact underneath.

What extending a model lets a developer add

Extending an existing model lets a developer add to it the things a model is made of. The developer can add a field, so the existing kind of record holds an additional genuine piece of information. The developer can add or adjust logic, so the existing kind of record does something more, or something adjusted, where the developer's logic should apply. So extending a model is how a developer makes an existing kind of record hold what the business genuinely needs it to hold, and do what the business genuinely needs it to do, beyond what it did by default.

Why extending is the clean way

Extending an existing model, rather than redefining it, is the clean way for the reasons extending is clean throughout Odoo. The extension adds just the genuine change, leaving the existing model, perhaps Odoo's own, intact, so the change is a clean, identifiable layer. This is maintainable, and it carries through upgrades far better: when Odoo's existing model changes in a new version, an extension that added just the genuine change adapts far more readily than a wholesale redefinition would. Redefining an existing model wholly would be fragile and a burden. Extending it through model inheritance is the clean, sound way.

The takeaway

Extending an existing Odoo model is how a developer changes what an existing kind of record holds or does: adding a field, so the record holds an additional genuine piece of information, or adding or adjusting logic, so the record does more. The principle is to extend, not redefine: through model inheritance, the developer adds the genuine change as a clean layer, while the existing model stays intact underneath. Extending is the clean way, maintainable and far better through upgrades than a wholesale redefinition. It is the central principle of clean Odoo development, applied to models. For how we approach Odoo, see our ERP practice.

All posts

Got a Topic Worth Posting?

Suggest a Topic

If a question keeps coming up in your operations, it might be worth its own post.