Skip to content

[19.0][FIX] document_page: history_head after content edit - #649

Open
XtremXpert wants to merge 1 commit into
OCA:19.0from
XtremXpert:19.0-fix-document_page-history_head
Open

XtremXpert wants to merge 1 commit into
OCA:19.0from
XtremXpert:19.0-fix-document_page-history_head

Conversation

@XtremXpert

Copy link
Copy Markdown

Problem

After editing the content of a page, history_head keeps pointing to the previous revision. On reload, the page shows the old content, so the edit looks lost (the new document.page.history record exists, but it is not the head).

_compute_history_head takes history_ids[0], relying on _order = "id DESC". In the cache, however, the revision created by _inverse_content() during write() is appended at the end of history_ids, so history_ids[0] is still the old revision when the stored history_head is recomputed.

Fix

Pick the newest revision explicitly: history_ids.sorted("id", reverse=True)[:1].

Tests

New test_page_edit_keeps_new_content: create a page, write new content, flush and invalidate, then check the head and the content.

On odoo:19.0 (Odoo Server 19.0-20260926):

  • without the fix: 1 failed, 0 error(s) of 10 tests (document.page.history(10,) != document.page.history(11,))
  • with the fix: 0 failed, 0 error(s) of 10 tests

The same issue and fix apply to the 20.0 migration (#647).

🤖 Generated with Claude Code

history_ids is not sorted by _order in the cache: the revision created by
write() is appended last, so history_ids[0] kept pointing to the previous
revision and the edited content was lost on reload.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants