1c8a95809852baefa851985507a07ac7f6465dc7
api.ondelete decorator
With this commit, a new ORM api decorator is introduced: `api.ondelete(*, at_uninstall)`. This decorator is to be applied to Model methods that check for specific business conditions when attempting to unlink a record via the interface. E.g. trying to unlink a validated journal entry This decorator allows this logic to exist outside the `BaseModel.unlink` method and is automatically bypassed when in uninstall mode, this means that during an uninstall any and all data related to a module can and will be removed easily and cleanly while still being able to apply business logic to manual deletion of records. This feature opens the gates to solving a very big problem with uninstalls: records and tables that remain in a database despite the relevant module being uninstalled, because if an override to unlink raises an error, the data will never be deleted from the database. Henceforth, overrides of unlink shall solely be used for data-cleaning purposes, i.e. deletion or modification of data that is related to the one currently being deleted but cannot be automatically deleted because there are no proper SQL relations. In certain very specific, low-level scenarios an unlink may be overridden to raise an error, but this should only be done if you know what the fuck you're doing, most of the time you'll want to resort to `@api.ondelete`. Note that this new decorator includes a keyword-only, required argument called `at_uninstall`, in most business cases this argument shall be False as this argument dictates whether or not this method should be executed in the `unlink` call during uninstall. It should only be set to True if you are certain of all the implications which most likely means that the records of the model in which this ondelete function is defined will NOT be removed during uninstall, they will forever linger in the DB until manual intervention, this in turn can mean a wide range of undefined problems due to crap left on the database. Following commits will replace any `unlink` overrides that raise business errors by methods decorated with `api.ondelete`, another commit will introduce a pylint checker that will raise a warning any time that an unlink override raises an error.
…
…
…
Odoo
Odoo is a suite of web based open source business apps.
The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...
Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.
Getting started with Odoo
For a standard installation please follow the Setup instructions from the documentation.
To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials
Languages
Python
49.6%
JavaScript
47.8%
SCSS
2%
CSS
0.3%
HTML
0.2%