[17.0][ADD] mail_attachment_xml_preview: preview XML attachments as a collapsible tree - #257
Conversation
pedrobaeza
left a comment
There was a problem hiding this comment.
Merging as already approved in the previous repository.
/ocabot merge nobump
|
On my way to merge this fine PR! |
|
@pedrobaeza your merge command was aborted due to failed check(s), which you can inspect on this commit of 17.0-ocabot-merge-pr-257-by-pedrobaeza-bump-nobump. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
|
/ocabot merge nobump |
|
This PR looks fantastic, let's merge it! |
|
Congratulations, your PR was merged at f7cd230. Thanks a lot for contributing to OCA. ❤️ |
Replaces OCA/knowledge#636: moved here and renamed after @pedrobaeza's suggestion, since the module is about mail attachments and is not a derivative of
attachment_preview.Summary
New module that renders XML attachments in the standard file viewer as an indented, collapsible tree instead of a wall of raw text.
Context
ir.attachment._check_contentsneutralizes xml-like mimetypes totext/plainfor every user without write access on views, so XML attachments end up in the plain-text branch of theFileViewer. Machine-generated XML (electronic invoices such as CFDI or UBL, bank statements, EDI messages) is usually serialized on a single line, which makes that preview unreadable.How it works
Attachmentmodel addsisXml(by extension, or by mimetype when it survives), removes those files from theisTextbranch and keeps them viewable.XmlViewerfetches the attachment, parses it withDOMParserand renders the tree with plain<details>/<summary>elements, so collapsing is native HTML: no library, no server-side conversion, no external service.Test plan
HttpCasethat loads the module suite in a real browser.