From feb45513f77962cc4b58334385afb66bcadc9141 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 29 Apr 2018 13:20:02 +1000 Subject: [PATCH] Prevent serial number for stock item with quantity > 1 --- InvenTree/part/models.py | 2 +- InvenTree/static/css/inventree.css | 4 ++++ InvenTree/stock/models.py | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 236649214f..9740d1ccc3 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -82,7 +82,7 @@ class Part(models.Model): """ Represents an abstract part Parts can be "stocked" in multiple warehouses, and can be combined to form other parts - """ + """ def get_absolute_url(self): return '/part/{id}/'.format(id=self.id) diff --git a/InvenTree/static/css/inventree.css b/InvenTree/static/css/inventree.css index 229ee025e6..d007287f89 100644 --- a/InvenTree/static/css/inventree.css +++ b/InvenTree/static/css/inventree.css @@ -85,4 +85,8 @@ .wrapper { align-items: stretch; display: flex; +} + +.help-inline { + color: #A11; } \ No newline at end of file diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index e2a3dc4f82..5f415cd8d9 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -73,6 +73,13 @@ class StockItem(models.Model): # TODO - Find a test than can be perfomed... pass + # Serial number cannot be set for items with quantity greater than 1 + if not self.quantity == 1 and self.serial: + raise ValidationError({ + 'quantity': _("Quantity must be set to 1 for item with a serial number"), + 'serial': _("Serial number cannot be set if quantity > 1") + }) + def get_absolute_url(self): return '/stock/item/{id}/'.format(id=self.id)