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 29a191e05e)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot] 2023-11-03 12:15:59 +11:00 committed by GitHub
parent a7c0882c02
commit 57e9497da1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -409,6 +409,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)