Skip to content

Commit

Permalink
Prevent settings from writing to the database during import (#5844) (#…
Browse files Browse the repository at this point in the history
…5845)

- Fixes conflicts which can occur due to importing duplicate settings from a data file

(cherry picked from commit 29a191e)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
  • Loading branch information
github-actions[bot] and SchrodingersGat committed Nov 3, 2023
1 parent a7c0882 commit 57e9497
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions InvenTree/common/models.py
Expand Up @@ -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)

Expand Down

0 comments on commit 57e9497

Please sign in to comment.