Allow creation of stockitem with non-integer quantity

-  Also provided more translation strings
This commit is contained in:
Oliver Walters 2019-11-19 10:00:08 +11:00
parent 0ea8ade26c
commit 003a2d9f3c
5 changed files with 319 additions and 76 deletions

View File

@ -1,12 +1,14 @@
{% load i18n %}
{% load inventree_extras %}
<div class='row'>
<h4>Allocate Stock to Build</h4>
<h4>{% trans "Allocate Stock to Build" %}</h4>
<div class='col-sm-6'>
</div>
<div class='col-sm-6'>
<div class='btn-group' style='float: right;'>
<button class='btn btn-primary' type='button' title='Automatic allocation' id='auto-allocate-build'>Auto Allocate</button>
<button class='btn btn-warning' type='button' title='Unallocate build stock' id='unallocate-build'>Unallocate</button>
<button class='btn btn-primary' type='button' title='Automatic allocation' id='auto-allocate-build'>{% trans "Auto Allocate" %}</button>
<button class='btn btn-warning' type='button' title='Unallocate build stock' id='unallocate-build'>{% trans "Unallocate" %}</button>
</div>
</div>
</div>
@ -14,16 +16,16 @@
<div class='row'>
<div class='col-sm-6'>
<h4>Part</h4>
<h4>{% trans "Part" %}</h4>
</div>
<div class='col-sm-2'>
<h4>Available</h4>
<h4>{% trans "Available" %}</h4>
</div>
<div class='col-sm-2'>
<h4>Required</h4>
<h4>{% trans "Required" %}</h4>
</div>
<div class='col-sm-2'>
<h4>Allocated</h4>
<h4>{% trans "Allocated" %}</h4>
</div>
</div>

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-18 22:51+0000\n"
"POT-Creation-Date: 2019-11-18 22:58+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -102,7 +102,8 @@ msgstr ""
msgid "Destroyed"
msgstr ""
#: InvenTree/status_codes.py:83 build/templates/build/allocate_view.html:21
#: InvenTree/status_codes.py:83 build/templates/build/allocate_edit.html:28
#: build/templates/build/allocate_view.html:21
msgid "Allocated"
msgstr ""
@ -149,6 +150,33 @@ msgstr ""
msgid "Allocated quantity ({n}) must not exceed available quantity ({q})"
msgstr ""
#: build/templates/build/allocate_edit.html:5
msgid "Allocate Stock to Build"
msgstr ""
#: build/templates/build/allocate_edit.html:10
msgid "Auto Allocate"
msgstr ""
#: build/templates/build/allocate_edit.html:11
msgid "Unallocate"
msgstr ""
#: build/templates/build/allocate_edit.html:19
#: build/templates/build/allocate_view.html:17
msgid "Part"
msgstr ""
#: build/templates/build/allocate_edit.html:22
#: build/templates/build/allocate_view.html:19
msgid "Available"
msgstr ""
#: build/templates/build/allocate_edit.html:25
#: build/templates/build/allocate_view.html:20
msgid "Required"
msgstr ""
#: build/templates/build/allocate_view.html:4
msgid "Required Parts"
msgstr ""
@ -161,28 +189,16 @@ msgstr ""
msgid "Order Parts"
msgstr ""
#: build/templates/build/allocate_view.html:17
msgid "Part"
msgstr ""
#: build/templates/build/allocate_view.html:18
#: part/templates/part/detail.html:32
msgid "Description"
msgstr ""
#: build/templates/build/allocate_view.html:19
msgid "Available"
msgstr ""
#: build/templates/build/allocate_view.html:20
msgid "Required"
msgstr ""
#: build/templates/build/allocate_view.html:22
msgid "On Order"
msgstr ""
#: build/views.py:289 stock/views.py:862
#: build/views.py:289 stock/views.py:863
#, python-brace-format
msgid "The following serial numbers already exist: ({sn})"
msgstr ""
@ -954,6 +970,26 @@ msgstr ""
msgid "Stock Item"
msgstr ""
#: stock/views.py:96
msgid "Edit Stock Location"
msgstr ""
#: stock/views.py:120
msgid "Stock Location QR code"
msgstr ""
#: stock/views.py:135
msgid "Stock Export Options"
msgstr ""
#: stock/views.py:243
msgid "Stock Item QR Code"
msgstr ""
#: stock/views.py:266
msgid "Adjust Stock"
msgstr ""
#: stock/views.py:375
msgid "Move Stock Items"
msgstr ""
@ -1020,10 +1056,54 @@ msgstr ""
msgid "Deleted {n} stock items"
msgstr ""
#: stock/views.py:841
#: stock/views.py:588
msgid "Edit Stock Item"
msgstr ""
#: stock/views.py:624
msgid "Create new Stock Location"
msgstr ""
#: stock/views.py:645
msgid "Serialize Stock"
msgstr ""
#: stock/views.py:725
msgid "Create new Stock Item"
msgstr ""
#: stock/views.py:789
msgid "Copy Stock Item"
msgstr ""
#: stock/views.py:839
msgid "Invalid quantity"
msgstr ""
#: stock/views.py:842
msgid "Invalid part selection"
msgstr ""
#: stock/views.py:903
#: stock/views.py:904
msgid "Created new stock item"
msgstr ""
#: stock/views.py:921
msgid "Delete Stock Location"
msgstr ""
#: stock/views.py:934
msgid "Delete Stock Item"
msgstr ""
#: stock/views.py:945
msgid "Delete Stock Tracking Entry"
msgstr ""
#: stock/views.py:962
msgid "Edit Stock Tracking Entry"
msgstr ""
#: stock/views.py:971
msgid "Add Stock Tracking Entry"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-18 22:51+0000\n"
"POT-Creation-Date: 2019-11-18 22:58+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -102,7 +102,8 @@ msgstr ""
msgid "Destroyed"
msgstr ""
#: InvenTree/status_codes.py:83 build/templates/build/allocate_view.html:21
#: InvenTree/status_codes.py:83 build/templates/build/allocate_edit.html:28
#: build/templates/build/allocate_view.html:21
msgid "Allocated"
msgstr ""
@ -149,6 +150,33 @@ msgstr ""
msgid "Allocated quantity ({n}) must not exceed available quantity ({q})"
msgstr ""
#: build/templates/build/allocate_edit.html:5
msgid "Allocate Stock to Build"
msgstr ""
#: build/templates/build/allocate_edit.html:10
msgid "Auto Allocate"
msgstr ""
#: build/templates/build/allocate_edit.html:11
msgid "Unallocate"
msgstr ""
#: build/templates/build/allocate_edit.html:19
#: build/templates/build/allocate_view.html:17
msgid "Part"
msgstr ""
#: build/templates/build/allocate_edit.html:22
#: build/templates/build/allocate_view.html:19
msgid "Available"
msgstr ""
#: build/templates/build/allocate_edit.html:25
#: build/templates/build/allocate_view.html:20
msgid "Required"
msgstr ""
#: build/templates/build/allocate_view.html:4
msgid "Required Parts"
msgstr ""
@ -161,28 +189,16 @@ msgstr ""
msgid "Order Parts"
msgstr ""
#: build/templates/build/allocate_view.html:17
msgid "Part"
msgstr ""
#: build/templates/build/allocate_view.html:18
#: part/templates/part/detail.html:32
msgid "Description"
msgstr ""
#: build/templates/build/allocate_view.html:19
msgid "Available"
msgstr ""
#: build/templates/build/allocate_view.html:20
msgid "Required"
msgstr ""
#: build/templates/build/allocate_view.html:22
msgid "On Order"
msgstr ""
#: build/views.py:289 stock/views.py:862
#: build/views.py:289 stock/views.py:863
#, python-brace-format
msgid "The following serial numbers already exist: ({sn})"
msgstr ""
@ -954,6 +970,26 @@ msgstr ""
msgid "Stock Item"
msgstr ""
#: stock/views.py:96
msgid "Edit Stock Location"
msgstr ""
#: stock/views.py:120
msgid "Stock Location QR code"
msgstr ""
#: stock/views.py:135
msgid "Stock Export Options"
msgstr ""
#: stock/views.py:243
msgid "Stock Item QR Code"
msgstr ""
#: stock/views.py:266
msgid "Adjust Stock"
msgstr ""
#: stock/views.py:375
msgid "Move Stock Items"
msgstr ""
@ -1020,10 +1056,54 @@ msgstr ""
msgid "Deleted {n} stock items"
msgstr ""
#: stock/views.py:841
#: stock/views.py:588
msgid "Edit Stock Item"
msgstr ""
#: stock/views.py:624
msgid "Create new Stock Location"
msgstr ""
#: stock/views.py:645
msgid "Serialize Stock"
msgstr ""
#: stock/views.py:725
msgid "Create new Stock Item"
msgstr ""
#: stock/views.py:789
msgid "Copy Stock Item"
msgstr ""
#: stock/views.py:839
msgid "Invalid quantity"
msgstr ""
#: stock/views.py:842
msgid "Invalid part selection"
msgstr ""
#: stock/views.py:903
#: stock/views.py:904
msgid "Created new stock item"
msgstr ""
#: stock/views.py:921
msgid "Delete Stock Location"
msgstr ""
#: stock/views.py:934
msgid "Delete Stock Item"
msgstr ""
#: stock/views.py:945
msgid "Delete Stock Tracking Entry"
msgstr ""
#: stock/views.py:962
msgid "Edit Stock Tracking Entry"
msgstr ""
#: stock/views.py:971
msgid "Add Stock Tracking Entry"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-18 22:51+0000\n"
"POT-Creation-Date: 2019-11-18 22:58+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -102,7 +102,8 @@ msgstr ""
msgid "Destroyed"
msgstr ""
#: InvenTree/status_codes.py:83 build/templates/build/allocate_view.html:21
#: InvenTree/status_codes.py:83 build/templates/build/allocate_edit.html:28
#: build/templates/build/allocate_view.html:21
msgid "Allocated"
msgstr ""
@ -149,6 +150,33 @@ msgstr ""
msgid "Allocated quantity ({n}) must not exceed available quantity ({q})"
msgstr ""
#: build/templates/build/allocate_edit.html:5
msgid "Allocate Stock to Build"
msgstr ""
#: build/templates/build/allocate_edit.html:10
msgid "Auto Allocate"
msgstr ""
#: build/templates/build/allocate_edit.html:11
msgid "Unallocate"
msgstr ""
#: build/templates/build/allocate_edit.html:19
#: build/templates/build/allocate_view.html:17
msgid "Part"
msgstr ""
#: build/templates/build/allocate_edit.html:22
#: build/templates/build/allocate_view.html:19
msgid "Available"
msgstr ""
#: build/templates/build/allocate_edit.html:25
#: build/templates/build/allocate_view.html:20
msgid "Required"
msgstr ""
#: build/templates/build/allocate_view.html:4
msgid "Required Parts"
msgstr ""
@ -161,28 +189,16 @@ msgstr ""
msgid "Order Parts"
msgstr ""
#: build/templates/build/allocate_view.html:17
msgid "Part"
msgstr ""
#: build/templates/build/allocate_view.html:18
#: part/templates/part/detail.html:32
msgid "Description"
msgstr ""
#: build/templates/build/allocate_view.html:19
msgid "Available"
msgstr ""
#: build/templates/build/allocate_view.html:20
msgid "Required"
msgstr ""
#: build/templates/build/allocate_view.html:22
msgid "On Order"
msgstr ""
#: build/views.py:289 stock/views.py:862
#: build/views.py:289 stock/views.py:863
#, python-brace-format
msgid "The following serial numbers already exist: ({sn})"
msgstr ""
@ -954,6 +970,26 @@ msgstr ""
msgid "Stock Item"
msgstr ""
#: stock/views.py:96
msgid "Edit Stock Location"
msgstr ""
#: stock/views.py:120
msgid "Stock Location QR code"
msgstr ""
#: stock/views.py:135
msgid "Stock Export Options"
msgstr ""
#: stock/views.py:243
msgid "Stock Item QR Code"
msgstr ""
#: stock/views.py:266
msgid "Adjust Stock"
msgstr ""
#: stock/views.py:375
msgid "Move Stock Items"
msgstr ""
@ -1020,10 +1056,54 @@ msgstr ""
msgid "Deleted {n} stock items"
msgstr ""
#: stock/views.py:841
#: stock/views.py:588
msgid "Edit Stock Item"
msgstr ""
#: stock/views.py:624
msgid "Create new Stock Location"
msgstr ""
#: stock/views.py:645
msgid "Serialize Stock"
msgstr ""
#: stock/views.py:725
msgid "Create new Stock Item"
msgstr ""
#: stock/views.py:789
msgid "Copy Stock Item"
msgstr ""
#: stock/views.py:839
msgid "Invalid quantity"
msgstr ""
#: stock/views.py:842
msgid "Invalid part selection"
msgstr ""
#: stock/views.py:903
#: stock/views.py:904
msgid "Created new stock item"
msgstr ""
#: stock/views.py:921
msgid "Delete Stock Location"
msgstr ""
#: stock/views.py:934
msgid "Delete Stock Item"
msgstr ""
#: stock/views.py:945
msgid "Delete Stock Tracking Entry"
msgstr ""
#: stock/views.py:962
msgid "Edit Stock Tracking Entry"
msgstr ""
#: stock/views.py:971
msgid "Add Stock Tracking Entry"
msgstr ""

View File

@ -21,7 +21,7 @@ from InvenTree.views import QRCodeView
from InvenTree.helpers import str2bool, DownloadFile, GetExportFormats
from InvenTree.helpers import ExtractSerialNumbers
from decimal import Decimal
from decimal import Decimal, InvalidOperation
from datetime import datetime
from company.models import Company
@ -93,7 +93,7 @@ class StockLocationEdit(AjaxUpdateView):
form_class = EditStockLocationForm
context_object_name = 'location'
ajax_template_name = 'modal_form.html'
ajax_form_title = 'Edit Stock Location'
ajax_form_title = _('Edit Stock Location')
def get_form(self):
""" Customize form data for StockLocation editing.
@ -117,7 +117,7 @@ class StockLocationEdit(AjaxUpdateView):
class StockLocationQRCode(QRCodeView):
""" View for displaying a QR code for a StockLocation object """
ajax_form_title = "Stock Location QR code"
ajax_form_title = _("Stock Location QR code")
def get_qr_data(self):
""" Generate QR code data for the StockLocation """
@ -132,7 +132,7 @@ class StockExportOptions(AjaxView):
""" Form for selecting StockExport options """
model = StockLocation
ajax_form_title = 'Stock Export Options'
ajax_form_title = _('Stock Export Options')
form_class = ExportOptionsForm
def post(self, request, *args, **kwargs):
@ -240,7 +240,7 @@ class StockExport(AjaxView):
class StockItemQRCode(QRCodeView):
""" View for displaying a QR code for a StockItem object """
ajax_form_title = "Stock Item QR Code"
ajax_form_title = _("Stock Item QR Code")
def get_qr_data(self):
""" Generate QR code data for the StockItem """
@ -263,7 +263,7 @@ class StockAdjust(AjaxView, FormMixin):
"""
ajax_template_name = 'stock/stock_adjust.html'
ajax_form_title = 'Adjust Stock'
ajax_form_title = _('Adjust Stock')
form_class = AdjustStockForm
stock_items = []
@ -585,7 +585,7 @@ class StockItemEdit(AjaxUpdateView):
form_class = EditStockItemForm
context_object_name = 'item'
ajax_template_name = 'modal_form.html'
ajax_form_title = 'Edit Stock Item'
ajax_form_title = _('Edit Stock Item')
def get_form(self):
""" Get form for StockItem editing.
@ -621,7 +621,7 @@ class StockLocationCreate(AjaxCreateView):
form_class = EditStockLocationForm
context_object_name = 'location'
ajax_template_name = 'modal_form.html'
ajax_form_title = 'Create new Stock Location'
ajax_form_title = _('Create new Stock Location')
def get_initial(self):
initials = super(StockLocationCreate, self).get_initial().copy()
@ -642,7 +642,7 @@ class StockItemSerialize(AjaxUpdateView):
model = StockItem
ajax_template_name = 'stock/item_serialize.html'
ajax_form_title = 'Serialize Stock'
ajax_form_title = _('Serialize Stock')
form_class = SerializeStockForm
def get_initial(self):
@ -722,7 +722,7 @@ class StockItemCreate(AjaxCreateView):
form_class = CreateStockItemForm
context_object_name = 'item'
ajax_template_name = 'modal_form.html'
ajax_form_title = 'Create new Stock Item'
ajax_form_title = _('Create new Stock Item')
def get_form(self):
""" Get form for StockItem creation.
@ -786,7 +786,7 @@ class StockItemCreate(AjaxCreateView):
try:
original = StockItem.objects.get(pk=item_to_copy)
initials = model_to_dict(original)
self.ajax_form_title = "Copy Stock Item"
self.ajax_form_title = _("Copy Stock Item")
except StockItem.DoesNotExist:
initials = super(StockItemCreate, self).get_initial().copy()
@ -831,11 +831,12 @@ class StockItemCreate(AjaxCreateView):
part_id = form['part'].value()
try:
part = Part.objects.get(id=part_id)
quantity = int(form['quantity'].value())
except (Part.DoesNotExist, ValueError):
quantity = Decimal(form['quantity'].value())
except (Part.DoesNotExist, ValueError, InvalidOperation):
part = None
quantity = 1
valid = False
form.errors['quantity'] = [_('Invalid quantity')]
if part is None:
form.errors['part'] = [_('Invalid part selection')]
@ -917,7 +918,7 @@ class StockLocationDelete(AjaxDeleteView):
success_url = '/stock'
ajax_template_name = 'stock/location_delete.html'
context_object_name = 'location'
ajax_form_title = 'Delete Stock Location'
ajax_form_title = _('Delete Stock Location')
class StockItemDelete(AjaxDeleteView):
@ -930,7 +931,7 @@ class StockItemDelete(AjaxDeleteView):
success_url = '/stock/'
ajax_template_name = 'stock/item_delete.html'
context_object_name = 'item'
ajax_form_title = 'Delete Stock Item'
ajax_form_title = _('Delete Stock Item')
class StockItemTrackingDelete(AjaxDeleteView):
@ -941,7 +942,7 @@ class StockItemTrackingDelete(AjaxDeleteView):
model = StockItemTracking
ajax_template_name = 'stock/tracking_delete.html'
ajax_form_title = 'Delete Stock Tracking Entry'
ajax_form_title = _('Delete Stock Tracking Entry')
class StockTrackingIndex(ListView):
@ -958,7 +959,7 @@ class StockItemTrackingEdit(AjaxUpdateView):
""" View for editing a StockItemTracking object """
model = StockItemTracking
ajax_form_title = 'Edit Stock Tracking Entry'
ajax_form_title = _('Edit Stock Tracking Entry')
form_class = TrackingEntryForm
@ -967,7 +968,7 @@ class StockItemTrackingCreate(AjaxCreateView):
"""
model = StockItemTracking
ajax_form_title = "Add Stock Tracking Entry"
ajax_form_title = _("Add Stock Tracking Entry")
form_class = TrackingEntryForm
def post(self, request, *args, **kwargs):