Prevent serial number for stock item with quantity > 1

This commit is contained in:
Oliver 2018-04-29 13:20:02 +10:00
parent 9ea3d7bf71
commit feb45513f7
3 changed files with 12 additions and 1 deletions

View File

@ -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)

View File

@ -85,4 +85,8 @@
.wrapper {
align-items: stretch;
display: flex;
}
.help-inline {
color: #A11;
}

View File

@ -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)