[18.0][FIX] payroll_contract_advantages: bound validation, data integrity and precision - #287
Open
CristianoMafraJunior wants to merge 1 commit into
Open
Conversation
Contributor
|
Hi @nimarosa, |
nimarosa
approved these changes
Aug 25, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken today
hr.contract.advantage._check_bound_limits()treats0.0as a real bound instead of"no limit on that side". Any
hr.contract.advantage.templateleft with the default(unset)
lower_bound/upper_boundtherefore rejects every non-zero amount,making the advantage type unusable until an admin discovers they must also fill in
bounds that have no
requiredflag or hint suggesting so.payroll_contract_advantages/models/hr_payslip.pybuilds a{code: amount}dict fromcontract.advantages_ids, so a duplicate line silently overwrites one amount with theother with no warning, and the resulting payslip total is wrong without any error
being raised.
hr.contract.advantage.templaterecords from sharing the samecode. That code is the key salary rules use to read the value (advantages.<CODE>),so a duplicate code makes two different advantages collide in the same computation.
hr.contract.advantage.contract_idis notrequiredand has noondelete, sodeleting a contract leaves orphaned
hr.contract.advantagerows withcontract_id = NULLinstead of being cleaned up.hr.contract.advantage.templateallows saving adefault_valueoutside its ownlower_bound/upper_bound, and allowslower_bound > upper_bound— analready-inconsistent template that only surfaces the problem later, when someone tries
to use it.
amount(on the advantage line) andlower_bound/upper_bound/default_value(on the template) use plain
Floatwith no digits precision, unlike the rest of thepayroll engine which consistently uses the
Payroll(2 decimals) precision formonetary-like amounts.
What this PR changes
hr_contract_advantage.py_check_bound_limits(): a bound of0.0is now treated as "not set", matching thecommon Odoo convention, instead of blocking every non-zero amount.
contract_id: nowrequired=True, ondelete="cascade".advantage_template_id: nowrequired=True.amount: now usesdigits="Payroll".contract_template_unique: one template per contract.hr_contract_advantage_template.pycode_unique._check_bounds_consistency(): rejectslower_bound > upper_boundand adefault_valueoutside the template's own bounds (same "0.0= no limit"convention).
lower_bound/upper_bound/default_value: now usedigits="Payroll".(
test_onchange_advantage_template_sets_default_amount) whose fixture value becameinconsistent with the new bound-consistency check.
cc @nimarosa @pedrobaeza