Prevent settings from writing to the database during import (#5844)

- Fixes conflicts which can occur due to importing duplicate settings from a data file
This commit is contained in:
Oliver 2023-11-03 11:58:22 +11:00 committed by GitHub
parent 92336f6b32
commit 29a191e05e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)