← All manuals Operator Guide for this screen IM2

RO Import History

RO Import History
Technical Spec Ver 1 Updated 2026-09-06 Matches the live screen

RO Import History — Technical Spec

Router: app/ro.py (ro_router, mounted at /ro after ro_import.router). Template: app/templates/ro_imports.html. Database: the ro database (ro_db()), not IM2.

Routes

MethodPathNotes
GET/ro/importsList screen. Query params search, mode, source_system, operator, days.
GET/ro/imports/exportCSV of the same filter, limit=100000. Filename RO_Import_History_<UTC date>.csv.

Both depend on current_user only — any signed-in role can read the log, including level3. There is no write route: the log is append-only, written by application code, never by the operator.

The same query also powers the imports block on the order detail screen (query_imports(conn, order_no=...), ro.py order route).

Data

ro_import_log, one row per import attempt, joined left join ro_header h on h.order_no = l.order_no for job_name / ro_type.

Columns written by log_import(): order_no, mode, operator, source_system, source_ref, source_kind, file_name, file_id, rev_no, lines_loaded, lines_changed, issues_raised, outcome, note (+ import_id, imported_at defaults).

source_system on this table carries the same CHECK constraint as ro_inbox / ro_header (see app/ro_import.py header comment — 'MANUAL' was added 2026-09-04 for uploads and hand-keyed orders).

Filtering (query_imports)

Rendering rules

Known limits / defects

  1. log_import() has no callers anywhere in the package (verified by grep over app/.py and scripts/ on 2026-09-06). The reader, the export and the order-detail block are all built; nothing in the shipped code writes the row. Any rows in ro_import_log today came from outside this code. Until an import path calls log_import(), this screen under-reports.
  2. Source filter values do not match what the importer stores. The dropdown offers FP / BT / Upload, while ro_import.py uses FP / BT / XLSX and, per Dave's 2026-09-04 ruling, stages uploads and hand-keyed orders as MANUAL. Selecting Upload will match nothing.
  3. No pagination — a filter wide enough to exceed LIST_LIMIT silently truncates the screen (the export is not truncated).
  4. The export writes raw values, including imported_at as a Python timestamp repr, not a formatted date string.

Shared table sort (2026-09-07)

Column sorting is one implementation in templates/base.html (Dave, 2026-09-07: "all screens that have tables like this need sorts on the appropriate columns"). A table opts in with class="sorttable"; every thead th becomes sortable except those with class="nosort"/class="toggle", an empty heading, or a checkbox in the heading. Client-side only, over the rows already rendered. Details: tech/table_sorting.md.