mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
migration for file-based currency setting
This commit is contained in:
parent
14c904c0c5
commit
5aaced6e66
23
InvenTree/common/migrations/0010_migrate_currency_setting.py
Normal file
23
InvenTree/common/migrations/0010_migrate_currency_setting.py
Normal 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),
|
||||
]
|
Loading…
Reference in New Issue
Block a user