From 43355904b03801a0b34a277bfde25b3ca86a6b1a Mon Sep 17 00:00:00 2001 From: Bobbe <34186858+30350n@users.noreply.github.com> Date: Mon, 12 Feb 2024 02:03:18 +0100 Subject: [PATCH] Fix uncaught Company.DoesNotExist error in SupplierBarcodeMixin (#6467) (#6469) --- InvenTree/plugin/base/barcodes/mixins.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/InvenTree/plugin/base/barcodes/mixins.py b/InvenTree/plugin/base/barcodes/mixins.py index 9576aef3a3..76fc0bfb4b 100644 --- a/InvenTree/plugin/base/barcodes/mixins.py +++ b/InvenTree/plugin/base/barcodes/mixins.py @@ -225,10 +225,10 @@ class SupplierBarcodeMixin(BarcodeMixin): return None if supplier_pk := self.get_setting("SUPPLIER_ID"): - if (supplier := Company.objects.get(pk=supplier_pk)): - return supplier - else: - logger.error( + try: + return Company.objects.get(pk=supplier_pk) + except Company.DoesNotExist: + logger.exception( "No company with pk %d (set \"SUPPLIER_ID\" setting to a valid value)", supplier_pk )