]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Handle the ASN assignment last, after the splitting (#5745)
authorTrenton H <797416+stumpylog@users.noreply.github.com>
Tue, 13 Feb 2024 16:26:13 +0000 (08:26 -0800)
committerGitHub <noreply@github.com>
Tue, 13 Feb 2024 16:26:13 +0000 (16:26 +0000)
src/documents/barcodes.py

index 5bf6226519f789991481c60e0ce224b90acfcf0e..fe1e94b8a25f8bd450c2e7fb5cdba61b8d38d50d 100644 (file)
@@ -87,14 +87,6 @@ class BarcodePlugin(ConsumeTaskPlugin):
         # Locate any barcodes in the files
         self.detect()
 
-        # Update/overwrite an ASN if possible
-        if (
-            settings.CONSUMER_ENABLE_ASN_BARCODE
-            and (located_asn := self.asn) is not None
-        ):
-            logger.info(f"Found ASN in barcode: {located_asn}")
-            self.metadata.asn = located_asn
-
         # try reading tags from barcodes
         if (
             settings.CONSUMER_ENABLE_TAG_BARCODE
@@ -154,6 +146,15 @@ class BarcodePlugin(ConsumeTaskPlugin):
             # Request the consume task stops
             raise StopConsumeTaskError(msg)
 
+        # Update/overwrite an ASN if possible
+        # After splitting, as otherwise each split document gets the same ASN
+        if (
+            settings.CONSUMER_ENABLE_ASN_BARCODE
+            and (located_asn := self.asn) is not None
+        ):
+            logger.info(f"Found ASN in barcode: {located_asn}")
+            self.metadata.asn = located_asn
+
     def cleanup(self) -> None:
         self.temp_dir.cleanup()