Daily updates from Odoo
Thursday, August 28, 2025
2 changes · 18.0
Code cleanup and technical improvements
This refactor simplifies how Odoo modules avoid heavy recalculations when new stored computed fields are added during installation. It makes the setup process easier for developers to understand and helps reduce the risk of memory issues on large databases, without changing day-to-day user workflows.
Original PR description
This commit adds a hook called on the `_auto_init` method to be called whenever a new computed stored field should not be computed when installing the module containing it. It is common for a new model to add an `_auto_init` extension method to create the column of a new computed stored field to prevent it from being computed. This is usually done to prevent MemoryError on large databases. The way it has been written is however not intuitive, as one would have to know non-existent columns are going to be computed when the column is created, and the way we have been preventing them would not be understood normally without reading the comments. This refactor makes it clear from the hook method name that we are adding fields that we intend to skip computation on, and is less complex and much more easier to understand at first glance. related-enterprise-PR: https://github.com/odoo/enterprise/pull/93193 task-5031330
This update simplifies how Odoo skips expensive background calculations when installing modules with certain stored computed fields. It helps reduce the risk of memory issues on large databases while making the setup logic easier for developers to understand and maintain.
Original PR description
This commit adds a hook called on the `_auto_init` method to be called whenever a new computed stored field should not be computed when installing the module containing it. It is common for a new model to add an `_auto_init` extension method to create the column of a new computed stored field to prevent it from being computed. This is usually done to prevent MemoryError on large databases. The way it has been written is however not intuitive, as one would have to know non-existent columns are going to be computed when the column is created, and the way we have been preventing them would not be understood normally without reading the comments. This refactor makes it clear from the hook method name that we are adding fields that we intend to skip computation on, and is less complex and much more easier to understand at first glance. related-community-PR: https://github.com/odoo/odoo/pull/224218 task-5031330