Skip to content

[T1523] - ADD: Preview PDF button on communication job - #2125

Merged
ecino merged 2 commits into
18.0from
T1523-country-map-photo-by-post
Aug 5, 2026
Merged

[T1523] - ADD: Preview PDF button on communication job#2125
ecino merged 2 commits into
18.0from
T1523-country-map-photo-by-post

Conversation

@danpa32

@danpa32 danpa32 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

T1523 — Country map/photo missing on German and Italian onboarding cards

Related PR: CompassionCH/compassion-switzerland#1783

Original report

The "sponsorship onboarding photo by post" physical communication (Sponsorship > Partner communication > Photo by card) should print a photo alongside the letter, but it only appears on French cards. It's also missing on Italian, so cards are currently being sent without it as a workaround.

Root cause

The QWeb report template (onboarding_photo_by_post.xml, partner_communication_switzerland) embeds its layout CSS as literal text inside <t t-set="custom_css">. Odoo's translation extraction treats that raw CSS text as translatable, and the German and Italian .po translations had the CSS property names themselves mistranslated — widthBreite/larghezza, heightHöhe/altezza, positionPosition: absolut/posizione: assoluta, colorFarbe/colore. That makes the #map positioning rule invalid CSS for German/Italian only, so the photo has no size/position and effectively vanishes. French's translation wasn't corrupted, which is why only French worked.

The same corruption exists identically in both the v14 and v18 i18n/de.po/it.po files — pre-existing, not introduced by the v14→v18 migration itself.

Separately (not a bug, confirmed intentional): the image itself is a circular community photo, not a literal country map — the map was replaced by a photo in a 2024 change and stays that way.

What changed

Two repos:

compassion-switzerland,

partner_communication_switzerland

  • report/onboarding_photo_by_post.xml: added t-translation="off" to the <t t-set="custom_css"> block so this CSS can never be mistranslated again.
  • i18n/de.po / i18n/it.po: corrected the corrupted translation entries.
  • migrations/18.0.1.1.1/post-migration.py: guarded DB fix intended to copy the French arch_db translation into de_DE/it_IT. In practice this turned out to be a no-op — t-translation="off" alone, combined with the ordinary module-upgrade data reload, was already enough to normalize arch_db across all installed languages (it collapses to one shared value, dropping the separate fr_CH key entirely).

compassion-modules,

partner_communication:

  • New "Preview PDF" button on the Communication Job form, next to the existing "Preview" button. The existing button only ever rendered raw HTML (_render_qweb_html) — never the actual PDF — so a broken/invisible image could go unnoticed until physical printing. The new button renders through the real ir.actions.report action instead.

How to test manually

  1. Upgrade partner_communication_switzerland (-u partner_communication_switzerland).
  2. Open a "Sponsorship Onboarding - Photo by post" communication job for a German or Italian sponsor, click Preview PDF (new button, next to Preview), confirm the photo renders, correctly positioned, same as French.
  3. Note: Preview PDF renders server-side via wkhtmltopdf, which needs the report.url system parameter to point at wherever the Odoo instance is actually being served from (http://127.0.0.1:<port> for local testing) — a stale report.url will show a blank white square where the image should be.

The existing Preview button only rendered raw HTML, never the actual PDF
report, so a broken image (a positioning/CSS bug, or a static asset that
fails to load) could go unnoticed until physical printing. Add a Preview PDF
button that renders through the real ir.actions.report action instead.
@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

Safe to merge; no blocking failure remains.

The changed preview action was executed through a focused harness using the method extracted from the repository source. It preserved the partner language, returned the report action for the selected job, and set the physical-printer bypass context.

T-Rex T-Rex Logs

What T-Rex did

  • Ran the preview PDF report harness before the fix and observed that the earlier method lacked a printer-bypass context and produced one modeled printer dispatch.
  • Ran the preview PDF report harness after the fix and observed that it ran with_context(lang='fr_CH', must_skip_send_to_printer=True), report_action([4125], config=False), and zero modeled printer dispatches.
  • The harness compiles and invokes the method AST from the parent communication_job.py rather than maintaining a copied implementation, confirming the preview action preserves the report contract while bypassing physical-printer routing.
  • Before capture in the second investigation, the harness exited 0 and reproduced the missing bypass context with one modeled printer call.
  • After capture, the harness exited 0 and proved with_context(lang='fr_CH', must_skip_send_to_printer=True), report_action([4125], config=False), and zero modeled printer calls, and it compiles by invoking the real method AST from the checked-out parent communication_job.py rather than a copied body.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (2): Last reviewed commit: "[T1523] FIX: Preview PDF must not reach ..." | Re-trigger Greptile

Comment thread partner_communication/models/communication_job.py Outdated
preview_pdf_report() called report_action() without
must_skip_send_to_printer=True, so previewing a report configured through
base_report_to_printer for physical printing produced a real printer job
instead of just serving the PDF to the browser.
@ecino
ecino merged commit cb758d1 into 18.0 Aug 5, 2026
2 checks passed
@ecino
ecino deleted the T1523-country-map-photo-by-post branch August 5, 2026 11:28
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