Merge pull request #605 from SchrodingersGat/order-receive-fix

Bug fix - receiving lines against a PO
This commit is contained in:
Oliver 2020-01-06 10:09:31 +11:00 committed by GitHub
commit 3def3e1e89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 81 additions and 22 deletions

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-05 21:52+0000\n"
"POT-Creation-Date: 2020-01-05 22:23+0000\n"
"PO-Revision-Date: 2019-12-19 17:48+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -429,24 +429,42 @@ msgstr "Notiz"
msgid "Notes"
msgstr "Notizen"
#: order/views.py:140
#: order/views.py:141
msgid "Confirm order cancellation"
msgstr "Bestell-Stornierung bestätigen"
#: order/views.py:173
#: order/views.py:174
msgid "Confirm order placement"
msgstr "Bestellungstätigung bestätigen"
#: order/views.py:731
#: order/views.py:328
#, fuzzy
#| msgid "Number of items received"
msgid "Items received"
msgstr "Empfangene Objekt-Anzahl"
#: order/views.py:342
msgid "No destination set"
msgstr ""
#: order/views.py:373
msgid "Error converting quantity to number"
msgstr ""
#: order/views.py:379
msgid "Receive quantity less than zero"
msgstr ""
#: order/views.py:740
msgid "Invalid Purchase Order"
msgstr "Ungültige Bestellung"
#: order/views.py:739
#: order/views.py:748
#, fuzzy
msgid "Supplier must match for Part and Order"
msgstr "Zulieferer muss zum Teil und zur Bestellung passen"
#: order/views.py:744
#: order/views.py:753
msgid "Invalid SupplierPart selection"
msgstr "Ungültige Wahl des Zulieferer-Teils"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-05 21:52+0000\n"
"POT-Creation-Date: 2020-01-05 22:23+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"
@ -420,23 +420,39 @@ msgstr ""
msgid "Notes"
msgstr ""
#: order/views.py:140
#: order/views.py:141
msgid "Confirm order cancellation"
msgstr ""
#: order/views.py:173
#: order/views.py:174
msgid "Confirm order placement"
msgstr ""
#: order/views.py:731
#: order/views.py:328
msgid "Items received"
msgstr ""
#: order/views.py:342
msgid "No destination set"
msgstr ""
#: order/views.py:373
msgid "Error converting quantity to number"
msgstr ""
#: order/views.py:379
msgid "Receive quantity less than zero"
msgstr ""
#: order/views.py:740
msgid "Invalid Purchase Order"
msgstr ""
#: order/views.py:739
#: order/views.py:748
msgid "Supplier must match for Part and Order"
msgstr ""
#: order/views.py:744
#: order/views.py:753
msgid "Invalid SupplierPart selection"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-05 21:52+0000\n"
"POT-Creation-Date: 2020-01-05 22:23+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"
@ -420,23 +420,39 @@ msgstr ""
msgid "Notes"
msgstr ""
#: order/views.py:140
#: order/views.py:141
msgid "Confirm order cancellation"
msgstr ""
#: order/views.py:173
#: order/views.py:174
msgid "Confirm order placement"
msgstr ""
#: order/views.py:731
#: order/views.py:328
msgid "Items received"
msgstr ""
#: order/views.py:342
msgid "No destination set"
msgstr ""
#: order/views.py:373
msgid "Error converting quantity to number"
msgstr ""
#: order/views.py:379
msgid "Receive quantity less than zero"
msgstr ""
#: order/views.py:740
msgid "Invalid Purchase Order"
msgstr ""
#: order/views.py:739
#: order/views.py:748
msgid "Supplier must match for Part and Order"
msgstr ""
#: order/views.py:744
#: order/views.py:753
msgid "Invalid SupplierPart selection"
msgstr ""

View File

@ -12,6 +12,7 @@ from django.views.generic import DetailView, ListView
from django.forms import HiddenInput
import logging
from decimal import Decimal, InvalidOperation
from .models import PurchaseOrder, PurchaseOrderLineItem
from .admin import POLineItemResource
@ -324,6 +325,8 @@ class PurchaseOrderReceive(AjaxUpdateView):
self.lines = []
self.destination = None
msg = _("Items received")
# Extract the destination for received parts
if 'location' in request.POST:
pk = request.POST['location']
@ -332,7 +335,11 @@ class PurchaseOrderReceive(AjaxUpdateView):
except (StockLocation.DoesNotExist, ValueError):
pass
errors = self.destination is None
errors = False
if self.destination is None:
errors = True
msg = _("No destination set")
# Extract information on all submitted line items
for item in request.POST:
@ -359,15 +366,17 @@ class PurchaseOrderReceive(AjaxUpdateView):
receive = self.request.POST[item]
try:
receive = int(receive)
except ValueError:
receive = Decimal(receive)
except InvalidOperation:
# In the case on an invalid input, reset to default
receive = line.remaining()
msg = _("Error converting quantity to number")
errors = True
if receive < 0:
receive = 0
errors = True
msg = _("Receive quantity less than zero")
line.receive_quantity = receive
self.lines.append(line)
@ -378,7 +387,7 @@ class PurchaseOrderReceive(AjaxUpdateView):
data = {
'form_valid': errors is False,
'success': 'Items marked as received',
'success': msg,
}
return self.renderJsonResponse(request, data=data, form=self.get_form())