mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-06 08:10:35 +00:00
Feature: store barcode contents, list and search them (#14276)
* Feature: store barcode contents, list and search them New setting PAPERLESS_CONSUMER_STORE_BARCODE_VALUES (off by default) stores all barcodes found during consumption with the document: page, type and content. They are listed on the metadata tab with a copy button, returned by the documents API and searchable with barcodes: in the advanced search. Versions keep their own barcodes, reprocessing reads them again. Refs #9898 * Tests: cover the remaining barcode branches Covers unchanged and failing barcode reads on reprocessing, unsupported files and DocumentBarcode.__str__, and uses toHaveLength in the barcode list spec as suggested by SonarCloud. * Address review: keep barcodes when they can't be read, format choices - Reprocessing and new versions keep the stored barcodes when the file can't be scanned or the scan fails, and replace them atomically. - Format is a TextChoices of the zxing-cpp formats, with a test. - Shared scan code, latest_version helper, TypedDict, serializer reuse. - Barcodes in the split manifest, export/import tests, pytest-style tests. * Barcode tests: TIFF reprocess, format check both ways, fixtures - Reprocessing a TIFF with TIFF support off keeps the stored barcodes. - The format test also fails when zxing-cpp drops a format. - Fixtures in place of the sample dir mixin, plugin-level disabled test. - Format labels aren't translated, OpenAPI enum named BarcodeFormatEnum. * Review: module-level zxing reader, shorter barcode docs - read_barcodes_zxing is a module-level function used by scan_pdf. - Drop the trivial __str__ test, mark it no cover. - Shorten the barcode docs and remove the duplicate in configuration.md. * Fix header * Use utility class * Return barcodes from the metadata endpoint only Drop the barcodes field and its prefetches from the document serializer, as agreed in the review. Also remove the now empty component stylesheet. --------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
co-authored by
shamoon
parent
312684aef3
commit
62cc31fbdb
@@ -1010,6 +1010,19 @@ documents to both separate and categorize them in a single operation.
|
||||
**Example:** A 6-page scan with TAG:invoice on page 3 and TAG:receipt on page 5 will create
|
||||
three documents: pages 1-2 (no tags), pages 3-4 (tagged "invoice"), and pages 5-6 (tagged "receipt").
|
||||
|
||||
### Barcode Contents {#barcode-contents}
|
||||
|
||||
By default, Paperless only uses barcodes for splitting, ASNs and tags. With
|
||||
[`PAPERLESS_CONSUMER_STORE_BARCODE_VALUES`](configuration.md#PAPERLESS_CONSUMER_STORE_BARCODE_VALUES)
|
||||
enabled, it stores the content of every barcode with the document, e.g. payment codes or QR codes.
|
||||
|
||||
- Barcodes are listed on the **Metadata** tab with page, type and content, and can be copied.
|
||||
- The API returns them in the `barcodes` field of `/api/documents/{id}/metadata/`.
|
||||
- They can be [searched](usage.md#searching-barcodes), e.g. `barcodes:DE89370400440532013000`.
|
||||
- Only the first [`PAPERLESS_CONSUMER_BARCODE_MAX_PAGES`](configuration.md#PAPERLESS_CONSUMER_BARCODE_MAX_PAGES)
|
||||
pages are scanned. Reprocessing reads the barcodes of existing documents.
|
||||
- Each version keeps its own barcodes, and the newest version's are shown and searched.
|
||||
|
||||
## Automatic collation of double-sided documents {#collate}
|
||||
|
||||
!!! note
|
||||
|
||||
@@ -1796,6 +1796,13 @@ assigns or creates tags if a properly formatted barcode is detected.
|
||||
|
||||
Defaults to false.
|
||||
|
||||
#### [`PAPERLESS_CONSUMER_STORE_BARCODE_VALUES=<bool>`](#PAPERLESS_CONSUMER_STORE_BARCODE_VALUES) {#PAPERLESS_CONSUMER_STORE_BARCODE_VALUES}
|
||||
|
||||
: Stores the content of every barcode found during consumption, see
|
||||
[Barcode Contents](advanced_usage.md#barcode-contents).
|
||||
|
||||
Defaults to false.
|
||||
|
||||
## Audit Trail
|
||||
|
||||
#### [`PAPERLESS_AUDIT_LOG_ENABLED=<bool>`](#PAPERLESS_AUDIT_LOG_ENABLED) {#PAPERLESS_AUDIT_LOG_ENABLED}
|
||||
|
||||
@@ -1061,6 +1061,20 @@ notes.user:alice notes.note:insurance
|
||||
|
||||
The bare `notes:` prefix is shorthand for `notes.note:`.
|
||||
|
||||
#### Searching barcodes
|
||||
|
||||
If [barcode contents are stored](advanced_usage.md#barcode-contents), they can be searched by
|
||||
content or type, but only with a field name:
|
||||
|
||||
```
|
||||
barcodes.value:DE89370400440532013000
|
||||
barcodes.format:qrcode
|
||||
barcodes:wifi barcodes:guest
|
||||
```
|
||||
|
||||
`barcodes:` is shorthand for `barcodes.value:`. Separators are stripped, so each part of e.g.
|
||||
`WIFI:S:Guest;P:secret;;` can be searched on its own.
|
||||
|
||||
All of these can be combined. Syntax not described here may not work as expected, and an unknown field name is searched as ordinary text.
|
||||
|
||||
!!! note
|
||||
|
||||
Reference in New Issue
Block a user