migration for file-based currency setting

This commit is contained in:
Matthias 2021-07-01 18:20:39 +02:00
parent 14c904c0c5
commit 5aaced6e66

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.4 on 2021-07-01 15:39
from django.db import migrations
from common.models import InvenTreeSetting
from InvenTree.settings import get_setting, CONFIG
def set_default_currency(apps, schema_editor):
""" migrate the currency setting from config.yml to db """
# get value from settings-file
base_currency = get_setting('INVENTREE_BASE_CURRENCY', CONFIG.get('base_currency', 'USD'))
# write to database
InvenTreeSetting.set_setting('INVENTREE_DEFAULT_CURRENCY', base_currency, None, create=True)
class Migration(migrations.Migration):
dependencies = [
('common', '0009_delete_currency'),
]
operations = [
migrations.RunPython(set_default_currency),
]