2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-04 04:30:56 +00:00

Simplify exhange rate backend

This commit is contained in:
Oliver Walters
2021-05-27 15:45:38 +10:00
parent 62320e46d5
commit af1904b6e4
10 changed files with 47 additions and 134 deletions

View File

@ -19,6 +19,8 @@ from djmoney.models.fields import MoneyField
from djmoney.contrib.exchange.models import convert_money
from djmoney.contrib.exchange.exceptions import MissingRate
from common.settings import currency_code_default
from django.utils.translation import ugettext_lazy as _
from django.core.validators import MinValueValidator, URLValidator
from django.core.exceptions import ValidationError
@ -80,20 +82,6 @@ class InvenTreeSetting(models.Model):
'default': '',
},
'INVENTREE_DEFAULT_CURRENCY': {
'name': _('Default Currency'),
'description': _('Default currency'),
'default': 'USD',
'choices': djmoney.settings.CURRENCY_CHOICES,
},
'CUSTOM_EXCHANGE_RATES': {
'name': _('Custom Exchange Rates'),
'description': _('Enable custom exchange rates'),
'validator': bool,
'default': False,
},
'INVENTREE_DOWNLOAD_FROM_URL': {
'name': _('Download from URL'),
'description': _('Allow download of remote images and files from external URL'),
@ -766,7 +754,7 @@ def get_price(instance, quantity, moq=True, multiples=True, currency=None):
if currency is None:
# Default currency selection
currency = InvenTreeSetting.get_setting('INVENTREE_DEFAULT_CURRENCY')
currency = currency_code_default()
pb_min = None
for pb in instance.price_breaks.all():