Skip to content

[FIX] document_page_reference: avoid duplicate reference on copy and enforce uniqueness - #634

Open
miquelrosell99 wants to merge 1 commit into
OCA:18.0from
miquelrosell99:18.0-fix-document-page-reference-unique
Open

[FIX] document_page_reference: avoid duplicate reference on copy and enforce uniqueness#634
miquelrosell99 wants to merge 1 commit into
OCA:18.0from
miquelrosell99:18.0-fix-document-page-reference-unique

Conversation

@miquelrosell99

Copy link
Copy Markdown

Before this fix:

  • Duplicating a document.page copied the reference value as-is, so the new page ended up with the same reference as the original.
  • The module only had a Python uniqueness check; there was no database-level unique constraint.

This fix:

  • Sets copy=False on the reference field so copies get a fresh reference generated from the copied page name.
  • Adds a SQL unique constraint on reference.
  • Includes a pre-migration script that clears duplicate references (keeping the oldest record) so the constraint can be applied on databases that already have duplicates.
  • Adds a regression test.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

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

@OCA-git-bot OCA-git-bot added series:18.0 mod:document_page_reference Module document_page_reference labels Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:document_page_reference Module document_page_reference series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants