A developer sometimes needs extra things to happen when records are created or changed. Overriding create and write does that, and it has to be done safely. This piece is about it.
Create and write
In Odoo, records are created and records are changed, and these are fundamental operations: creating a record, and writing changes to an existing one. Odoo has standard behaviour for these, what genuinely happens when a record is created or written. A developer can extend that standard behaviour, so that extra things happen when records of a kind are created or changed. That extending is overriding create and write.
Why a developer overrides them
A developer overrides create or write when something extra genuinely needs to happen at the point a record is created or changed: some logic, some additional action, that should occur whenever a record of that kind is created, or whenever one is changed. Overriding create or write is how a developer attaches that extra behaviour to those fundamental operations.
The key to doing it safely: extend, do not replace
The central principle of overriding create and write safely is this: the override should extend the standard behaviour, not replace it. When a developer overrides create or write, Odoo's standard behaviour for creating or writing the record still genuinely needs to happen, the record genuinely created, the changes genuinely written. The override should add the extra behaviour around or alongside the standard behaviour, ensuring the standard behaviour still genuinely runs. An override that adds extra behaviour but, in doing so, fails to let the standard create or write genuinely happen breaks the fundamental operation, which is a serious fault. Overriding create and write safely means the override extends, the standard behaviour still runs, and the developer's extra behaviour is added on top.
Why this matters so much
Getting this right matters so much because create and write are fundamental: a great deal depends on records being genuinely created and changed correctly. An override that breaks the standard create or write does not break some minor thing; it breaks a fundamental operation, with wide consequences. So overriding create and write is a place for genuine care: the developer must ensure the standard behaviour still genuinely happens, and add the extra behaviour without disturbing it. This is the safety in overriding create and write safely.
Work with the framework
Overriding create and write safely is, like all Odoo development, a matter of doing it the Odoo way. Odoo has an established, correct way to override these operations such that the standard behaviour is genuinely preserved and the extra behaviour is added. A developer overriding create or write should do it within Odoo's conventions, the established correct way, which is what ensures the override extends safely rather than breaking the standard operation. Following the framework's way is, in large part, what doing it safely means.
The takeaway
Overriding create and write in Odoo lets a developer extend what happens when records are created or changed, attaching extra behaviour to those fundamental operations. The key to doing it safely is that the override must extend, not replace, the standard behaviour: Odoo's standard create or write still genuinely has to happen, with the extra behaviour added around it. This matters greatly because create and write are fundamental, and an override that breaks them breaks a fundamental operation. Override create and write the Odoo way, with genuine care. For how we approach Odoo, see our ERP practice.