
Beyond the Syntax: How onchange, depends and inverse Really Work in Odoo
The Problem Ask any Odoo developer to explain the difference between @api.depends and @api.onchange , and you'll get some version of the same answer: "onchange is for the UI - it fires when the user changes a field in the form. depends is for computed fields - it runs when you save." It's not wrong. But it's incomplete in ways that matter. And that incompleteness quietly causes bugs, unnecessary code, wasted debugging hours, and team arguments about why something "sometimes works and sometimes doesn't." Here's what that incomplete understanding looks like in practice: a developer notices that a computed field isn't updating in the form view, so they add @api.onchange on top of @api.depends . It works. They ship it. Nobody questions it. Six months later someone else looks at that code and wonders: do we need both? what does each one actually do here? Or a developer implements two fields that should stay in sync - change one, the other updates automatically. They set up compute and inver
Continue reading on Dev.to Python
Opens in a new tab



