2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

Merge remote-tracking branch 'inventree/master'

This commit is contained in:
Oliver Walters
2019-09-09 15:03:57 +10:00
7 changed files with 61 additions and 32 deletions

View File

@ -188,12 +188,12 @@ class StockItem(models.Model):
if self.part.variant_of is not None:
if StockItem.objects.filter(part__variant_of=self.part.variant_of, serial=self.serial).exclude(id=self.id).exists():
raise ValidationError({
'serial': _('A part with this serial number already exists for template part {part}'.format(part=self.part.variant_of))
'serial': _('A stock item with this serial number already exists for template part {part}'.format(part=self.part.variant_of))
})
else:
if StockItem.objects.filter(serial=self.serial).exclude(id=self.id).exists():
if StockItem.objects.filter(part=self.part, serial=self.serial).exclude(id=self.id).exists():
raise ValidationError({
'serial': _('A part with this serial number already exists')
'serial': _('A stock item with this serial number already exists')
})
except Part.DoesNotExist:
pass

View File

@ -223,6 +223,9 @@ class StockExport(AjaxView):
stock_items = stock_items.filter(customer=None)
stock_items = stock_items.filter(belongs_to=None)
# Pre-fetch related fields to reduce DB queries
stock_items = stock_items.prefetch_related('part', 'supplier_part__supplier', 'location', 'purchase_order', 'build')
# Column headers
headers = [
_('Stock ID'),