From 29a191e05e605d9def9022558eea4a29b8f517d9 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 3 Nov 2023 11:58:22 +1100 Subject: [PATCH] Prevent settings from writing to the database during import (#5844) - Fixes conflicts which can occur due to importing duplicate settings from a data file --- InvenTree/common/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 340ecc83a1..69ab8decf0 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -494,6 +494,14 @@ class BaseInvenTreeSetting(models.Model): # Unless otherwise specified, attempt to create the setting create = kwargs.pop('create', True) + # Prevent saving to the database during data import + if InvenTree.ready.isImportingData(): + create = False + + # Prevent saving to the database during migrations + if InvenTree.ready.isRunningMigrations(): + create = False + # Perform cache lookup by default do_cache = kwargs.pop('cache', True)