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

@ -86,3 +86,7 @@
align-items: stretch; align-items: stretch;
display: flex; display: flex;
} }
.help-inline {
color: #A11;
}

View File

@ -73,6 +73,13 @@ class StockItem(models.Model):
# TODO - Find a test than can be perfomed... # TODO - Find a test than can be perfomed...
pass 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): def get_absolute_url(self):
return '/stock/item/{id}/'.format(id=self.id) return '/stock/item/{id}/'.format(id=self.id)