Skip to content

[18.0][FIX] document_page: do not copy history on page duplicate - #633

Open
miquelrosell99 wants to merge 2 commits into
OCA:18.0from
miquelrosell99:18.0-fix-document-page-copy-history
Open

miquelrosell99 wants to merge 2 commits into
OCA:18.0from
miquelrosell99:18.0-fix-document-page-copy-history

Conversation

@miquelrosell99

@miquelrosell99 miquelrosell99 commented Jul 31, 2026 •

Copy link
Copy Markdown

When duplicating a document.page, the One2many history_ids field was being copied by default, so the new page inherited all past revisions including their current state.

This PR adds copy=False on:

  • document.page.history_ids so duplicates start with a clean history.
  • document.page.history approval fields (state, approved_date, approved_uid) so a duplicated change request resets to draft and does not inherit approval metadata.

Tests are included for both behaviors.

@OCA-git-bot OCA-git-bot added mod:document_page Module document_page series:18.0 mod:document_page_approval Module document_page_approval labels Jul 31, 2026
@miquelrosell99
miquelrosell99 force-pushed the 18.0-fix-document-page-copy-history branch 2 times, most recently from 95bddc8 to 7352bc5 Compare July 31, 2026 09:54
When duplicating a document.page, the One2many history_ids field was
being copied by default, so the new page inherited all past revisions
including their current state.

Add copy=False on document.page.history_ids so duplicates start with a
clean history. Add copy=False on the approval-specific fields of
document.page.history (state, approved_date, approved_uid) so a duplicated
change request resets to draft and does not inherit approval metadata.

In document_page_approval, override copy() so the duplicated page starts
with a single draft change request containing the original content, rather
than reusing copied histories or auto-advancing to 'to approve'.

Add tests covering both behaviors.
@miquelrosell99
miquelrosell99 force-pushed the 18.0-fix-document-page-copy-history branch from 7352bc5 to ee0c108 Compare November 2, 2026 07:26
@oca-cla-bot

oca-cla-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

…e copy

The base document_page.copy() writes content=self.content in its
default, which overrides the content=False the approval copy() tried
to pass; the content inverse then created a change request on top of
the one created explicitly, leaving the duplicated page with two
history records.

Let the inverse create a single change request, but keep it in draft
when the page requires approval so the copy starts the approval
workflow from scratch instead of firing approval requests. When
approval is not required the record is auto-approved as usual, so the
copy keeps displaying its content.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:document_page_approval Module document_page_approval mod:document_page Module document_page series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants