Skip to content

[FIX] document_page_reference: migrate widget to OWL#601

Open
IJOL wants to merge 2 commits intoOCA:16.0from
BITVAX:16.0-fix-document-page-reference-owl
Open

[FIX] document_page_reference: migrate widget to OWL#601
IJOL wants to merge 2 commits intoOCA:16.0from
BITVAX:16.0-fix-document-page-reference-owl

Conversation

@IJOL
Copy link

@IJOL IJOL commented Mar 20, 2026

Summary

The legacy JS widget registered in web.field_registry is not picked up by the OWL form view parser in Odoo 16, causing:

  • Missing widget: document_page_reference for field of type html warning in browser console
  • content_parsed field not rendering — users see raw ${reference} text instead of clickable links

Changes

  • Migrate JS widget to OWL: Replace odoo.define + web.field_registry with @odoo-module + registry.category("fields"), extending HtmlField from @web_editor
  • Fix retargetLinks interference: The base HtmlField adds target="_blank" to all <a> tags via retargetLinks. The new widget removes this attribute from internal .oe_direct_line links so reference navigation stays within the same window
  • Override _get_page_index: Category index links now use oe_direct_line class with data-oe-model/data-oe-id attributes, making them compatible with the widget's click handler
  • Replace CSS class approach: oe_read_only/oe_edit_only classes replaced with readonly="1" and attrs/invisible for proper field visibility in Odoo 16 form views
  • Fix _compute_content_parsed bug: Was using self instead of record inside the loop, causing incorrect computation for multi-record sets
  • Add tour test: Browser test that verifies reference links render as clickable <a> tags and category index links are present

Test plan

  • Open a document page containing ${reference_name} references
  • Verify references render as clickable links (not raw text)
  • Click a reference link — should navigate to the target page within the same window (no new tab)
  • Open a category page — verify child page links are clickable and navigate correctly
  • Run document_page_reference test suite (Python + tour)

@OCA-git-bot
Copy link
Contributor

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

The legacy JS widget registered in web.field_registry was not picked up
by the OWL form view parser, causing "Missing widget:
document_page_reference" warnings and the content_parsed field not
rendering at all.

Changes:
- Migrate JS widget from legacy field_registry to OWL registry
- Fix retargetLinks adding target="_blank" to internal reference links
- Override _get_page_index to use oe_direct_line links in category pages
- Replace oe_read_only/oe_edit_only CSS classes with proper attrs/invisible
- Add tour test for reference link navigation
- Fix _compute_content_parsed using self instead of record in loop
@IJOL IJOL force-pushed the 16.0-fix-document-page-reference-owl branch 2 times, most recently from 77f41b2 to 54c8843 Compare March 20, 2026 10:46
html_escape() returns markupsafe.Markup, which auto-escapes plain str
when concatenated. Use Markup() for HTML literals to prevent the index
links from being double-escaped.

Also add sanitize=False to content_parsed field to match content field.
@IJOL IJOL force-pushed the 16.0-fix-document-page-reference-owl branch from 54c8843 to 910ad00 Compare March 20, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants