From f3bf86c016955c5d4a1ec325e3d30697cdef5ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20J=C3=BCrges?= Date: Sat, 8 Jun 2024 16:07:43 +0200 Subject: [PATCH] Added feature "CONSUMER_ENABLE_ASN0_SPLITTING" This feature will change the behaviour of the document barcode consumer. If CONSUMER_ENABLE_ASN0_SPLITTING=true, detection a ASN of value 0 will NOT write that ASN into the new document metadata. This achieves document splitting on ASN0 --- src/documents/barcodes.py | 3 ++- src/paperless/settings.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/documents/barcodes.py b/src/documents/barcodes.py index 2e290a61b..e4a138f98 100644 --- a/src/documents/barcodes.py +++ b/src/documents/barcodes.py @@ -154,7 +154,8 @@ class BarcodePlugin(ConsumeTaskPlugin): and (located_asn := self.asn) is not None ): logger.info(f"Found ASN in barcode: {located_asn}") - self.metadata.asn = located_asn + if not settings.CONSUMER_ENABLE_ASN0_SPLITTING or located_asn > 0: + self.metadata.asn = located_asn def cleanup(self) -> None: self.temp_dir.cleanup() diff --git a/src/paperless/settings.py b/src/paperless/settings.py index c4e70f68a..0e2db2626 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -893,6 +893,10 @@ CONSUMER_ENABLE_ASN_BARCODE: Final[bool] = __get_boolean( "PAPERLESS_CONSUMER_ENABLE_ASN_BARCODE", ) +CONSUMER_ENABLE_ASN0_SPLITTING: Final[bool] = __get_boolean( + "PAPERLESS_CONSUMER_ENABLE_ASN0_SPLITTING", +) + CONSUMER_ASN_BARCODE_PREFIX: Final[str] = os.getenv( "PAPERLESS_CONSUMER_ASN_BARCODE_PREFIX", "ASN",