-
-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[11.0] [BUG] Fix date range type unlink. #9
[11.0] [BUG] Fix date range type unlink. #9
Conversation
aa2df69
to
3c88efa
Compare
date_range/models/date_range_type.py
Outdated
@@ -26,3 +26,10 @@ def _default_company(self): | |||
_sql_constraints = [ | |||
('date_range_type_uniq', 'unique (name,company_id)', | |||
'A date range type must be unique per company !')] | |||
|
|||
@api.multi | |||
def unlink(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, use ondelete='restrict'
in the many2one in date.range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pedrobaeza I know, but i wanted to track the exact error, and to benefit from it to super method in OCA/account-financial-tools#636, because there the super was not covered in tests, red build, and i only had an postgres integrity error, and wanted to track it as odoo error..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can test it the same. Just use:
with self.assertRaises(Exception):
with self.env.cr.savepoint():
self.date_range_type.unlink()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pedrobaeza Updated, but i think is fine if i leave also the unlink method, to have a nice error message for the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is code to maintain. Generic error is clear enough IMO.
e3c356f
to
449a5fb
Compare
It would be convenient to split in 2 commits: one for the unlink problem, and another for pylint warnings, coding removal, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splitting commits would is nice to have, but otherwise 👍
I will do it later. Thanks for review. |
449a5fb
to
e4c6beb
Compare
🍏 |
Thanks |
No description provided.