feat(attachments): multi-annex embed for Sales Invoice (part 1)#263
Open
dafrose wants to merge 17 commits into
Open
feat(attachments): multi-annex embed for Sales Invoice (part 1)#263dafrose wants to merge 17 commits into
dafrose wants to merge 17 commits into
Conversation
Pin legacy embed behaviour with YAML scenarios (empty field, local 916, https and /api/method/ remote uri_id) and Drafthorse assertions on mocked find_file_by_url. Ignore .vscode/ in the app repo.
Replace _embed_attachment with get_legacy_embed_attachment and _embed_attachments so create_einvoice passes a URL list. Add integration test and before_tests fixtures so embed tests use governed master data instead of site-specific rows.
…ation Introduce E Invoice Attachment Row, einvoice_attachments on Sales Invoice, multi_attachment_embed_enabled setting, first-row-wins dedup on validate, and Desk attach-button UX.
Branch create_einvoice on get_embed_attachments; move attachment resolution to sales_invoice_attachments; consolidate tests and helpers.
Move einvoice_embedded_document into einvoice_attachments when multi-attachment embed is enabled, with per-save migration on Sales Invoice validate and a deduplicated bulk RQ job from E Invoice Settings. Lock the legacy attach field when multi-embed is on, fail embed on missing File rows, and add integration coverage for migration, lockdown, and broken links.
…units Add an integration test that embeds a table annex through attach_xml_to_pdf and verifies the payload survives extraction from the hybrid Factur-X PDF. Introduce shared helpers for minimal PDF bytes and CII AttachmentBinaryObject assertions. Remove unit tests for deduplicate_attachment_rows, get_legacy_embed_attachment, and mocked get_table_embed_attachments; those paths are already covered by integration tests.
Regenerate POT/PO from the attachment migration strings and translate 23 new and 1 adapted msgid in de.po.
3e495c6 to
53520f4
Compare
Member
Author
Add an Include submitted Sales Invoices option on the E Invoice Settings migrate button. Draft invoices still migrate via save; submitted invoices use direct child-row inserts and db.set_value so post-submit restrictions do not block the job. Replace the bulk migration integration test with a draft/submitted × include_submitted matrix and cancel submitted fixtures before teardown.
Throw when an einvoice_attachments row points at a File without a file_url, load File rows via the normal get_doc path during legacy embed resolution, and restrict site-wide migration to System Manager.
Member
Author
d3710c5 to
d0582ca
Compare
barredterra
reviewed
Jun 17, 2026
Restructure attachment test coverage: split get_embed_attachments branching into subTest cases, drop redundant table-principles unit class, extract URL-order resolver checks, and restore multi-embed settings in integration setUp/tearDown. Move set_multi_attachment_embed_enabled and assert_single_orange_message into tests/helpers.py. Add integration coverage for bulk migration of cancelled submitted invoices and prefer a positive docstatus check in bulk_migrate_legacy_embed_attachments. Regenerate fixtures to update attachment row schema and enable file id field visibility, for the row filter to work on Sales Invoice Attachments table.
d0582ca to
a5c5022
Compare
Share hidden/read_only flags via legacy_embed_field_lockdown_properties() so get_custom_fields and set_legacy_embed_field_lockdown stay aligned. This prevents after_install and migrate patches from re-exposing the legacy attach field when multi-attachment embedding is enabled.
barredterra
reviewed
Jun 19, 2026
barredterra
reviewed
Jun 19, 2026
Give operators explicit feedback when bulk legacy-embed migration hits unresolvable URLs: skip (Error Log, field unchanged) or remove (clear field, site warning log). Add a dialog toggle, split the job summary into skipped, removed, and error counts, and restrict the enqueue API to POST.
077bfb3 to
49cfcc5
Compare
…elated validation errors
Show an orange msgprint when per-save migration cannot resolve einvoice_embedded_document, in addition to the existing Error Log. Guide invoice owners to ask a System Manager to run bulk migration on E Invoice Settings. Remove unused _log_removed_broken_legacy_embed (inlined in _handle_broken_legacy_embed). Add tests for the validate warning and bulk migration summary segments.
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
Member
Author
Expand Google-style docstrings on embed resolution, legacy migration, bulk migrate APIs, and test helpers. Regenerate locale catalogs and translate milestone 1 user-facing strings in de.po for the multi-annex embed settings, migration dialog, and Sales Invoice annex grid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Part 1 of selectable PDF annexes for Sales Invoice (#261, coordination #76). This PR is supposed to only add support for multiple attachments via the same embedding path as before. File attachments are still embedded into XML (which may be embedded into PDF). It does not provide support for embedding additional files directly into PDF. This is planned for a follow-up PR.
When Multiple Attachment Embedding is enabled on E Invoice Settings, annexes are selected from the new
einvoice_attachmentschild table and embedded in the e-invoice XML as 916 supporting documents (same_embed_attachmentsloop as today). When the setting is off, behaviour stays on the legacyeinvoice_embedded_documentattach field.einvoice_attachmentschild table on Sales Invoice with Desk attach button and first-row-wins dedup on validatemulti_attachment_embed_enabledcheckbox on E Invoice Settingsget_embed_attachmentsbranches between table and legacy field; shared modulesales_invoice_attachments.pyget_legacy_embed_attachment+_embed_attachmentsURL loop (no change to hybrid PDF mechanics yet — annex bytes still travel inside embedded Factur-X XML)Not in this PR (possible follow-ups): PDF/A-3 factur-x pipeline with N PDF file attachments (#262), profile-aware 916 encoding, MIME allowlist, v15/develop backports.
Settings:

Migration Button UI:

Sales Invoice EInvoice tab:

Test plan
bench --site <site> run-tests --app eu_einvoice --lightmode— 22 tests greeneinvoice_embedded_documentonly → save with setting on → row appears in Embedded Documents, legacy field cleared, orange migration messageeinvoice_attachments→ submit/download PDF → annex payloads present in embedded Factur-X XML (Desk spot-check or XML download)Notes for reviewers
attach_xml_to_pdfstill embeds invoice XML only; new integration test verifies table annex content survives the PDF round-trip inside that XML.version-16-hotfixper rollout plan; develop backport differs (patch migration drops legacy field).Ticket Ref
LMK-16