From 57e9497da1f9cfa715cc8240c3078e7a64bef4de Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 12:15:59 +1100 Subject: [PATCH] Prevent settings from writing to the database during import (#5844) (#5845) - Fixes conflicts which can occur due to importing duplicate settings from a data file (cherry picked from commit 29a191e05e605d9def9022558eea4a29b8f517d9) Co-authored-by: Oliver --- InvenTree/common/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index f6dc80a8c11..e4f583475b3 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -409,6 +409,14 @@ def get_setting_object(cls, key, **kwargs): # 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)