[FIX] base_tier_validation: prevent copy of review_ids on duplication#57
Closed
bosd wants to merge 1 commit into
Closed
[FIX] base_tier_validation: prevent copy of review_ids on duplication#57bosd wants to merge 1 commit into
bosd wants to merge 1 commit into
Conversation
Add `copy=False` to the `review_ids` One2many field so that tier-review
records are not carried over when a validated record is duplicated.
Without this, `ORM.copy()` silently clones all `tier.review` rows to the
new record. Stored compute fields that depend on `review_ids` are then
re-evaluated inside `create()` against a partially-initialised record,
which can raise errors such as:
TypeError: argument of type 'bool' is not iterable
in models (e.g. `account.move`) that run non-trivial logic during
`_compute_needed_terms` or similar.
Duplicates should always start as a clean, unvalidated draft with no
inherited approval history.
Contributor
|
Hi @LoisRForgeFlow, |
yp-oerp
suggested changes
Jul 21, 2026
yp-oerp
left a comment
Member
There was a problem hiding this comment.
Thanks for the PR, but I don't think this change has any effect. By default in Odoo One2many fields have copy=False. I also tested on OCA runbot but I wasn't able to produce the issue.
Contributor
Author
|
Thanks @yp-oerp — you're right. One2many fields default to |
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.
Summary
Add
copy=Falseto thereview_idsOne2manyfield inTierValidationMixin.Root cause
The
review_idsfield is declared withoutcopy=False. When a userduplicates any record that uses the
TierValidationMixin(e.g. a postedvendor bill after validation), the ORM silently clones every
tier.reviewrow onto the new record.
Stored compute fields that depend on
review_idsare re-evaluated insidecreate()against this partially-initialised state. In models that runnon-trivial logic during their own stored compute fields this can raise:
(Seen in
account.move._compute_needed_termswhenbase_tier_validationis combined with
account_move_tier_validation.)More broadly, a duplicated record should begin as a clean, unvalidated draft
with no inherited approval history — the current behaviour is almost never
what users expect.
Fix
One line: add
copy=Falseto thereview_idsfield declaration.This is equivalent to what
res.partnerdoes forbank_ids, and followsOdoo's own pattern for relationship fields that should not be inherited by
duplicates.
Testing
Tested by duplicating a validated record (
account.movewithbase_tier_validation) and confirming:review_ids.request_validation()on the duplicate works normally.