Skip to content

[FIX] base_tier_validation: prevent copy of review_ids on duplication#57

Closed
bosd wants to merge 1 commit into
OCA:19.0from
bosd:19.0-fix-base_tier_validation-copy-review-ids
Closed

[FIX] base_tier_validation: prevent copy of review_ids on duplication#57
bosd wants to merge 1 commit into
OCA:19.0from
bosd:19.0-fix-base_tier_validation-copy-review-ids

Conversation

@bosd

@bosd bosd commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Add copy=False to the review_ids One2many field in TierValidationMixin.

Root cause

The review_ids field is declared without copy=False. When a user
duplicates any record that uses the TierValidationMixin (e.g. a posted
vendor bill after validation), the ORM silently clones every tier.review
row onto the new record.

Stored compute fields that depend on review_ids are re-evaluated inside
create() against this partially-initialised state. In models that run
non-trivial logic during their own stored compute fields this can raise:

TypeError: argument of type 'bool' is not iterable

(Seen in account.move._compute_needed_terms when base_tier_validation
is 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=False to the review_ids field declaration.

review_ids = fields.One2many(
    ...
    copy=False,
)

This is equivalent to what res.partner does for bank_ids, and follows
Odoo's own pattern for relationship fields that should not be inherited by
duplicates.

Testing

Tested by duplicating a validated record (account.move with
base_tier_validation) and confirming:

  1. The duplicate is created without error.
  2. The duplicate has no review_ids.
  3. Calling request_validation() on the duplicate works normally.

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.
@OCA-git-bot

Copy link
Copy Markdown
Contributor

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

@OCA-git-bot OCA-git-bot added mod:base_tier_validation Module base_tier_validation series:19.0 labels Jul 17, 2026

@yp-oerp yp-oerp left a comment

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.

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.

@bosd

bosd commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @yp-oerp — you're right. One2many fields default to copy=False in Odoo (confirmed in 19.0 source), so this change is a no-op. The duplicated-reviews behavior I ran into originated from a client-side customization (a Studio field / glue module), not from base_tier_validation itself. Closing this as unnecessary. Thanks for the review!

@bosd bosd closed this Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:base_tier_validation Module base_tier_validation series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants