From 7c91c9ba799a3c4a5288bda2e627d45a9c78f211 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 25 Apr 2019 03:13:41 +1000 Subject: [PATCH] Reverse URL for stock models - stock location - stock item - stock tracking - Added blank test files --- InvenTree/stock/models.py | 7 ++++--- InvenTree/stock/test_stock_item.py | 4 ++++ InvenTree/stock/test_stock_location.py | 3 +++ InvenTree/stock/test_stock_tracking.py | 4 ++++ InvenTree/stock/tests.py | 3 --- 5 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 InvenTree/stock/test_stock_item.py create mode 100644 InvenTree/stock/test_stock_location.py create mode 100644 InvenTree/stock/test_stock_tracking.py delete mode 100644 InvenTree/stock/tests.py diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 6af5b3d4b7..312bff9bbe 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals from django.utils.translation import gettext_lazy as _ from django.core.exceptions import ValidationError +from django.urls import reverse from django.db import models, transaction from django.core.validators import MinValueValidator @@ -25,7 +26,7 @@ class StockLocation(InvenTreeTree): """ def get_absolute_url(self): - return '/stock/location/{id}/'.format(id=self.id) + return reverse('stock-location-detail', kwargs={'pk': self.id}) @property def stock_items(self): @@ -109,7 +110,7 @@ class StockItem(models.Model): }) def get_absolute_url(self): - return '/stock/item/{id}/'.format(id=self.id) + return reverse('stock-item-detail', kwargs={'pk': self.id}) class Meta: unique_together = [ @@ -331,7 +332,7 @@ class StockItemTracking(models.Model): """ def get_absolute_url(self): - return '/stock/track/{id}/'.format(id=self.id) + return reverse('stock-tracking-detail', kwargs={'pk': self.id}) # Stock item item = models.ForeignKey(StockItem, on_delete=models.CASCADE, diff --git a/InvenTree/stock/test_stock_item.py b/InvenTree/stock/test_stock_item.py new file mode 100644 index 0000000000..0b4501e258 --- /dev/null +++ b/InvenTree/stock/test_stock_item.py @@ -0,0 +1,4 @@ +from django.test import TestCase + +# Create your tests here. + diff --git a/InvenTree/stock/test_stock_location.py b/InvenTree/stock/test_stock_location.py new file mode 100644 index 0000000000..7ce503c2dd --- /dev/null +++ b/InvenTree/stock/test_stock_location.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/InvenTree/stock/test_stock_tracking.py b/InvenTree/stock/test_stock_tracking.py new file mode 100644 index 0000000000..0b4501e258 --- /dev/null +++ b/InvenTree/stock/test_stock_tracking.py @@ -0,0 +1,4 @@ +from django.test import TestCase + +# Create your tests here. + diff --git a/InvenTree/stock/tests.py b/InvenTree/stock/tests.py deleted file mode 100644 index a79ca8be56..0000000000 --- a/InvenTree/stock/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.test import TestCase - -# Create your tests here.