mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Fix: Splitting on ASN barcodes even if not enabled (#5740)
* Fixes the barcodes always splitting on ASNs, even if splitting was disabled
This commit is contained in:
parent
1197437750
commit
21f96f0679
@ -88,21 +88,28 @@ class BarcodePlugin(ConsumeTaskPlugin):
|
|||||||
self.detect()
|
self.detect()
|
||||||
|
|
||||||
# Update/overwrite an ASN if possible
|
# Update/overwrite an ASN if possible
|
||||||
located_asn = self.asn
|
if (
|
||||||
if located_asn is not None:
|
settings.CONSUMER_ENABLE_ASN_BARCODE
|
||||||
|
and (located_asn := self.asn) is not None
|
||||||
|
):
|
||||||
logger.info(f"Found ASN in barcode: {located_asn}")
|
logger.info(f"Found ASN in barcode: {located_asn}")
|
||||||
self.metadata.asn = located_asn
|
self.metadata.asn = located_asn
|
||||||
|
|
||||||
# try reading tags from barcodes
|
# try reading tags from barcodes
|
||||||
if settings.CONSUMER_ENABLE_TAG_BARCODE:
|
if (
|
||||||
tags = self.tags
|
settings.CONSUMER_ENABLE_TAG_BARCODE
|
||||||
if tags is not None and len(tags) > 0:
|
and (tags := self.tags) is not None
|
||||||
|
and len(tags) > 0
|
||||||
|
):
|
||||||
if self.metadata.tag_ids:
|
if self.metadata.tag_ids:
|
||||||
self.metadata.tag_ids += tags
|
self.metadata.tag_ids += tags
|
||||||
else:
|
else:
|
||||||
self.metadata.tag_ids = tags
|
self.metadata.tag_ids = tags
|
||||||
logger.info(f"Found tags in barcode: {tags}")
|
logger.info(f"Found tags in barcode: {tags}")
|
||||||
|
|
||||||
|
# Lastly attempt to split documents
|
||||||
|
if settings.CONSUMER_ENABLE_BARCODES:
|
||||||
|
|
||||||
separator_pages = self.get_separation_pages()
|
separator_pages = self.get_separation_pages()
|
||||||
if not separator_pages:
|
if not separator_pages:
|
||||||
return "No pages to split on!"
|
return "No pages to split on!"
|
||||||
|
@ -402,6 +402,7 @@ class TestBarcode(
|
|||||||
|
|
||||||
self.assertEqual(len(documents), 2)
|
self.assertEqual(len(documents), 2)
|
||||||
|
|
||||||
|
@override_settings(CONSUMER_ENABLE_BARCODES=True)
|
||||||
def test_separate_pages_no_list(self):
|
def test_separate_pages_no_list(self):
|
||||||
"""
|
"""
|
||||||
GIVEN:
|
GIVEN:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user