feat(reports): add Reports tab — PDF diagnostics + Capture - #44
Open
Kimkhoi3010 wants to merge 2 commits into
Open
Kimkhoi3010 wants to merge 2 commits into
Kimkhoi3010 wants to merge 2 commits into
Conversation
Kimkhoi3010
force-pushed
the
feat/reports-db-panel
branch
from
September 22, 2026 04:38
148a4aa to
4c305ba
Compare
odoo-db's diagnostics command is now named reports (trobz/odoo-db#34), so the tab name and the odoo-db command match by default — no override needed, same as Mail today.
This branch has not been deployed
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.
Depend on
https://github.com/trobz/odoo-db/pull/34Summary
Adds a Reports tab to the database pane — diagnostics + a capture tool for PDF report generation failures (
wkhtmltopdf), built around a real incident:foodcoop18staging, 2026-07-06/07, a Stock Valuation Report PDF that generated with no error but no CSS at all, only diagnosable by hand-finding and re-running the actualwkhtmltopdfcommand on the host.Diagnostics
Reportstab runs odoo-db's newwkhtmltopdf <db>command (trobz/odoo-db#<PR_NUMBER>) —report.url/report.delay,report_wkhtmltopdf_param(OCA reporting-engine) install state + its per-paperformat overrides if installed — rendered as its own set of tables like Mail/Neutralization, since it answers one nested object, not a flat row list.wkhtmltopdf --versionrunning (probes.wkhtmltopdf_version), and PDF-related pip packages in the instance's own venv (probes.pdf_pip_packages, reusing the existingVIRTUAL_ENV-resolution precedent_resolve_argv0already uses).database "test" does not exist): Capture doesn't need odoo-db, so the button has to survive a Diagnostics fetch failing.Capture
wkhtmltopdfprocess Odoo runs on that instance (not just the highlighted database — apsrow has no way to name which database on a multi-tenant instance triggered it). A dedicated 2s-interval timer, zero-cost when nothing is armed.~/.oa-reports/before Odoo deletes them — usually within a second or two of the process exiting, so the backup has to happen the moment the process is seen, not after it exits.self._dbtab.rows), so it gets/search and Enter-to-open-raw-json ("Inspect": the full command, parsed<base href>/CSS asset links) for free, same as any other db tab.Ccopies the selected report's exact reproduce command to the clipboard,Xruns it and shows the real result inline — the actual point of Capture, getting wkhtmltopdf's real error instead of guessing from Odoo's generic failure message.Result
Verified live against a real local Postgres database (seeded with realistic data —
report.urldeliberately stale,report_wkhtmltopdf_paraminstalled with per-paperformat overrides) and a real running process standing in for an Odoo instance (a script matching_looks_like_odoo's detection, spawning a fakewkhtmltopdfchild with real temp files on real trigger) — not mocked, not the automated test suite.1. Diagnostics — full data
report.url/report.delayset (deliberately stale, the foodcoop18 shape),report_wkhtmltopdf_paramshown installed, per-paperformat overrides table (A4, US Letter) rendering correctly.2. Capture armed, nothing caught yet
Enable Capturepressed — confirm toast, tab switches to the (empty) captured-report table, action button flips toDisable Capture.3. A real report caught
A real
wkhtmltopdfprocess spawned on the fake instance — caught within one poll tick, listed as row#1with pid, captured time, full command, and backup directory.4. Inspect — raw json
Enteron the row — the generic raw-json drill-in every db tab already has, showing the full captured command plusbase_href/css_linksparsed out of the backed-up body HTML.5.
C— copy reproduce commandConfirms the exact captured command is on the clipboard, ready to paste into a real shell.
6.
X— run reproduce commandRe-runs the captured command for real and shows the actual failure inline (
HostNotFoundErroron the stalereport.url's asset URLs — mimicking exactly the foodcoop18 case) instead of Odoo's generic "report failed" message.Backup directory on disk after step 3, confirmed to hold all four temp files (cookie jar, header, footer, body HTML):
Test plan
make check(ruff lint/format, ty)make test(full suite, 210 passing)tests/test_probes.py:parse_wkhtmltopdf_argv(temp files + positionals extracted, missing flags absent not crashing),parse_report_html(<base href>+ known CSS links found, empty body handled),backup_wkhtmltopdf_capture(files saved under their basenames, unreadable file skipped without raising),wkhtmltopdf_version,pdf_pip_packagestests/test_tui.py(real Textual pilot,arm_capture/_do_poll_capture/selected_db_rowdriven directly): full capture flow (baseline poll catches nothing, a genuinely new pid gets backed up and appears live with no manual refresh, Disable keeps the list), Diagnostics-before-anything-armed,C/Xact on the row under the cursorfoodcoop18staging databases; Capture against a real running process, real temp files, real backup directory;C/Xagainst a real captured rowsite-docs/docs/keybindings.mdupdated — newC/Xbindings, Reports/Capture section