mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Specify default currency when creating a new stock item
This commit is contained in:
parent
51d2d85c26
commit
391eeb0e46
@ -14,6 +14,8 @@ from django.urls import reverse
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from moneyed import CURRENCIES
|
||||
|
||||
from InvenTree.views import AjaxView
|
||||
from InvenTree.views import AjaxUpdateView, AjaxDeleteView, AjaxCreateView
|
||||
from InvenTree.views import QRCodeView
|
||||
@ -32,6 +34,8 @@ from report.models import TestReport
|
||||
from label.models import StockItemLabel
|
||||
from .models import StockItem, StockLocation, StockItemTracking, StockItemAttachment, StockItemTestResult
|
||||
|
||||
import common.settings
|
||||
|
||||
from .admin import StockItemResource
|
||||
|
||||
from . import forms as StockForms
|
||||
@ -1572,6 +1576,8 @@ class StockItemCreate(AjaxCreateView):
|
||||
initials['location'] = part.get_default_location()
|
||||
initials['supplier_part'] = part.default_supplier
|
||||
|
||||
currency_code = common.settings.currency_code_default()
|
||||
|
||||
# SupplierPart field has been specified
|
||||
# It must match the Part, if that has been supplied
|
||||
if sup_part_id:
|
||||
@ -1581,6 +1587,8 @@ class StockItemCreate(AjaxCreateView):
|
||||
if part is None or supplier_part.part == part:
|
||||
initials['supplier_part'] = supplier_part
|
||||
|
||||
currency_code = supplier_part.supplier.currency_code
|
||||
|
||||
except (ValueError, SupplierPart.DoesNotExist):
|
||||
pass
|
||||
|
||||
@ -1592,6 +1600,11 @@ class StockItemCreate(AjaxCreateView):
|
||||
except (ValueError, StockLocation.DoesNotExist):
|
||||
pass
|
||||
|
||||
currency = CURRENCIES.get(currency_code, None)
|
||||
|
||||
if currency:
|
||||
initials['purchase_price'] = (None, currency)
|
||||
|
||||
return initials
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user