-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] no-raise-unlink: Check if there is raise sentence in unlink met…
…hod (#458) Raising errors inside unlink(), especially when inherited can leave stale data behind, therefore they are prohibited. This lint checks for that. Closes OCA/odoo-pre-commit-hooks#73. Context: odoo/odoo@1c8a958
- Loading branch information
Showing
5 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
testing/resources/test_repo/test_module/res_partner_unlink.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from odoo import models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = 'res.partner' | ||
|
||
def unlink(self): | ||
if self.name == 'explode': | ||
raise RuntimeError() | ||
|
||
return super().unlink() |
16 changes: 16 additions & 0 deletions
16
testing/resources/test_repo/test_module/sale_order_unlink.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import platform | ||
from odoo.models import Model | ||
|
||
if platform.system() == 'Windows': | ||
raise OSError | ||
|
||
|
||
class SaleOrder(Model): | ||
_name = 'sale.order' | ||
|
||
def unlink(self): | ||
if self.name == 'maybe': | ||
if self.status == 'explosive': | ||
raise Exception() | ||
|
||
return super().unlink() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters