-
-
Notifications
You must be signed in to change notification settings - Fork 574
[18.0][IMP] product_contract - add constraints #1316
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
base: 18.0
Are you sure you want to change the base?
[18.0][IMP] product_contract - add constraints #1316
Conversation
|
Hi @sbejaoui, |
cfb98b3 to
fe0e004
Compare
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.
Errors that will displayed to the user must be translatable.
ValidationError doesn't handle on itself the translation of the message. You must use env._ or from odoo import _
| return | ||
| if product.auto_renew_interval <= 0: | ||
| raise ValidationError( | ||
| f"Value of {product._fields['auto_renew_interval'].string}" |
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 want to make your error message translatable by wrapping them in env._ .
Be aware that vars included in the string will be evaluated inside the source string to translate.
https://www.odoo.com/documentation/18.0/developer/howtos/translations.html
What you want should be pretty close to this:
https://github.com/odoo/odoo/blob/18.0/addons/web_editor/models/ir_ui_view.py#L84-L88
| return | ||
| if product.termination_notice_interval < 0: | ||
| raise ValidationError( | ||
| f"Value of {product._fields['termination_notice_interval'].string}" |
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.
To make it translatable.
| if not line.is_contract or not line.is_auto_renew: | ||
| return | ||
| if line.auto_renew_interval <= 0: | ||
| raise ValidationError( |
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.
This one as translatable too.
08e1205 to
9065320
Compare
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.
Thanks for the changes, LGTM
9065320 to
2bcf56c
Compare
|
Also added constraints to limit the range of:
|
2bcf56c to
4e4b846
Compare
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.
Thanks, these constraints are a very good contribution 👍🏼
|
This PR has the |
Add 2 constraints to limit the range of: