From 3999ae60db0d5ca60562ed35629eae1f8b6572c5 Mon Sep 17 00:00:00 2001 From: wolflu05 <76838159+wolflu05@users.noreply.github.com> Date: Mon, 15 Jul 2024 00:32:24 +0200 Subject: [PATCH] remove short qr prefix validators and fix short qr detection regex --- .../InvenTree/plugin/builtin/barcodes/inventree_barcode.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/InvenTree/plugin/builtin/barcodes/inventree_barcode.py b/src/backend/InvenTree/plugin/builtin/barcodes/inventree_barcode.py index bde4a1069c..a16e29673e 100644 --- a/src/backend/InvenTree/plugin/builtin/barcodes/inventree_barcode.py +++ b/src/backend/InvenTree/plugin/builtin/barcodes/inventree_barcode.py @@ -11,7 +11,6 @@ import json import re from typing import cast -from django.core.validators import MaxLengthValidator, MinLengthValidator from django.utils.translation import gettext_lazy as _ import plugin.base.barcodes.helper @@ -45,7 +44,6 @@ class InvenTreeInternalBarcodePlugin(SettingsMixin, BarcodeMixin, InvenTreePlugi 'description': _( 'Customize the prefix used for short barcodes, may be useful for environments with multiple InvenTree instances' ), - 'validator': [str, MinLengthValidator(4), MaxLengthValidator(4)], 'default': 'INV-', }, } @@ -63,7 +61,9 @@ class InvenTreeInternalBarcodePlugin(SettingsMixin, BarcodeMixin, InvenTreePlugi # Attempt to match the barcode data against the short barcode format prefix = cast(str, self.get_setting('SHORT_BARCODE_PREFIX')) if type(barcode_data) is str and ( - m := re.match(f'^{re.escape(prefix)}(\\w{"{2}"})(\\d+)$', barcode_data) + m := re.match( + f'^{re.escape(prefix)}([0-9A-Z $%*+-.\\/:]{"{2}"})(\\d+)$', barcode_data + ) ): model_type_code, pk = m.groups()