Skip to content

[18.0][IMP] product_contract - add constraints#1316

Open
anthonissen-a wants to merge 2 commits into
OCA:18.0from
acsone:18.0-product_contract_add_constraints-aan
Open

[18.0][IMP] product_contract - add constraints#1316
anthonissen-a wants to merge 2 commits into
OCA:18.0from
acsone:18.0-product_contract_add_constraints-aan

Conversation

@anthonissen-a
Copy link
Copy Markdown

Add 2 constraints to limit the range of:

  • auto_renew_interval: to be strictly positive
  • termination_notice_interval: to be positive

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @sbejaoui,
some modules you are maintaining are being modified, check this out!

@anthonissen-a anthonissen-a force-pushed the 18.0-product_contract_add_constraints-aan branch 6 times, most recently from cfb98b3 to fe0e004 Compare October 16, 2025 09:36
Copy link
Copy Markdown
Member

@yvaucher yvaucher left a 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}"
Copy link
Copy Markdown
Member

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}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it translatable.

Comment thread product_contract/models/sale_order_line_contract_mixin.py
@anthonissen-a anthonissen-a force-pushed the 18.0-product_contract_add_constraints-aan branch 2 times, most recently from 08e1205 to 9065320 Compare October 17, 2025 14:41
Copy link
Copy Markdown
Member

@yvaucher yvaucher left a 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

@anthonissen-a anthonissen-a changed the title [IMP] product_contract - add constraints [18.0][IMP] product_contract - add constraints Oct 17, 2025
@anthonissen-a anthonissen-a force-pushed the 18.0-product_contract_add_constraints-aan branch from 9065320 to 2bcf56c Compare October 17, 2025 21:03
@anthonissen-a
Copy link
Copy Markdown
Author

Also added constraints to limit the range of:

  • recurrence_number: to be strictly positive
  • recurring_interval: to be strictly positive

@anthonissen-a anthonissen-a force-pushed the 18.0-product_contract_add_constraints-aan branch from 2bcf56c to 4e4b846 Compare October 17, 2025 21:08
Copy link
Copy Markdown
Member

@mamcode mamcode left a 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 👍🏼

@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@github-actions
Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Feb 22, 2026
@pedrobaeza pedrobaeza added this to the 18.0 milestone Feb 23, 2026
Comment thread product_contract/models/product_template.py Outdated
Comment thread product_contract/models/product_template.py Outdated
Comment thread product_contract/models/product_template.py Outdated
Comment thread product_contract/models/product_template.py Outdated
@pedrobaeza pedrobaeza removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Feb 23, 2026
anthonissen-a and others added 2 commits April 14, 2026 09:17
Co-authored-by: Pedro M. Baeza <pedro.baeza@tecnativa.com>
@anthonissen-a anthonissen-a force-pushed the 18.0-product_contract_add_constraints-aan branch from dde3aa1 to 5a409fe Compare April 14, 2026 07:19
@OCA-git-bot OCA-git-bot added the mod:product_contract Module product_contract label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants