mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fixed default currency selection
This commit is contained in:
parent
23db7a89a9
commit
3ab058e84b
@ -44,7 +44,7 @@ def money_kwargs():
|
||||
""" returns the database settings for MoneyFields """
|
||||
kwargs = {}
|
||||
kwargs['currency_choices'] = common.settings.currency_code_mappings()
|
||||
kwargs['default_currency'] = common.settings.currency_code_default
|
||||
kwargs['default_currency'] = common.settings.currency_code_default()
|
||||
return kwargs
|
||||
|
||||
|
||||
@ -86,6 +86,7 @@ class InvenTreeMoneyField(MoneyField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
# override initial values with the real info from database
|
||||
kwargs.update(money_kwargs())
|
||||
print(kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ import json
|
||||
import os.path
|
||||
from PIL import Image
|
||||
|
||||
from decimal import Decimal, InvalidOperation
|
||||
from decimal import Decimal
|
||||
|
||||
from wsgiref.util import FileWrapper
|
||||
from django.http import StreamingHttpResponse
|
||||
|
@ -18,8 +18,6 @@ from djmoney.settings import CURRENCY_CHOICES
|
||||
from djmoney.contrib.exchange.models import convert_money
|
||||
from djmoney.contrib.exchange.exceptions import MissingRate
|
||||
|
||||
import common.settings
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.validators import MinValueValidator, URLValidator
|
||||
from django.core.exceptions import ValidationError
|
||||
@ -781,6 +779,7 @@ def get_price(instance, quantity, moq=True, multiples=True, currency=None, break
|
||||
- If MOQ (minimum order quantity) is required, bump quantity
|
||||
- If order multiples are to be observed, then we need to calculate based on that, too
|
||||
"""
|
||||
from common.settings import currency_code_default
|
||||
|
||||
if hasattr(instance, break_name):
|
||||
price_breaks = getattr(instance, break_name).all()
|
||||
@ -804,7 +803,7 @@ def get_price(instance, quantity, moq=True, multiples=True, currency=None, break
|
||||
|
||||
if currency is None:
|
||||
# Default currency selection
|
||||
currency = common.settings.currency_code_default()
|
||||
currency = currency_code_default()
|
||||
|
||||
pb_min = None
|
||||
for pb in price_breaks:
|
||||
|
@ -8,15 +8,14 @@ from __future__ import unicode_literals
|
||||
from moneyed import CURRENCIES
|
||||
from django.conf import settings
|
||||
|
||||
import common.models
|
||||
|
||||
|
||||
def currency_code_default():
|
||||
"""
|
||||
Returns the default currency code (or USD if not specified)
|
||||
"""
|
||||
from common.models import InvenTreeSetting
|
||||
|
||||
code = common.models.InvenTreeSetting.get_setting('INVENTREE_DEFAULT_CURRENCY')
|
||||
code = InvenTreeSetting.get_setting('INVENTREE_DEFAULT_CURRENCY')
|
||||
|
||||
if code not in CURRENCIES:
|
||||
code = 'USD'
|
||||
@ -42,5 +41,6 @@ def stock_expiry_enabled():
|
||||
"""
|
||||
Returns True if the stock expiry feature is enabled
|
||||
"""
|
||||
from common.models import InvenTreeSetting
|
||||
|
||||
return common.models.InvenTreeSetting.get_setting('STOCK_ENABLE_EXPIRY')
|
||||
return InvenTreeSetting.get_setting('STOCK_ENABLE_EXPIRY')
|
||||
|
Loading…
Reference in New Issue
Block a user