OCA / odoo-pre-commit-hooks

Linters of Odoo addons that complement pylint-odoo
GNU Affero General Public License v3.0
10 stars 12 forks source link

Prevent raises inside unlink method #73

Closed luisg123v closed 1 year ago

luisg123v commented 1 year ago

Starting from Odoo 15.0, the unlink() method should not raise any exception [1]. Instead, a method decorated with @api.ondelete should be implemented, to prevent deletion constraints to be triggered when uninstalling modules.

[1] https://github.com/odoo/odoo/commit/1c8a95809852baefa851985507a07ac7f6465dc7

CC @moylop260 @antonag32 @edy1192 @deivislaya

antonag32 commented 1 year ago

I think this should be moved to pylint-odoo, thoughts?

luisg123v commented 1 year ago

Yes, you are right.

antonag32 commented 1 year ago

Sounds good, thanks for the report, I will start looking into it

luisg123v commented 1 year ago

BTW, the commit where the lint was introduced sais:

another commit will introduce a pylint checker that will raise a warning any time that an unlink override raises an error.

So it would be worth it checking whether that was already implemented.

antonag32 commented 1 year ago

I looked around Odoo's commit history and found no reference to the checker, also installed a module that raises exceptions inside an unlink (and triggered them) and no warnings were found during installation or execution so I guess it was never implemented.