diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index fc864ecc19..fe97d9a90c 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import os from django.db import models +from django.urls import reverse def rename_company_image(instance, filename): @@ -56,7 +57,7 @@ class Company(models.Model): return "{n} - {d}".format(n=self.name, d=self.description) def get_absolute_url(self): - return "/company/{id}/".format(id=self.id) + return reverse('company-detail', kwargs={'pk': self.id}) @property def part_count(self): diff --git a/InvenTree/company/tests.py b/InvenTree/company/tests.py index a79ca8be56..f1aa580c12 100644 --- a/InvenTree/company/tests.py +++ b/InvenTree/company/tests.py @@ -1,3 +1,19 @@ -# from django.test import TestCase +from django.test import TestCase -# Create your tests here. +from .models import Company + + +class CompanySimpleTest(TestCase): + + def setUp(self): + Company.objects.create(name='ABC Co.', + description='Seller of ABC products', + website='www.abc-sales.com', + address='123 Sales St.', + is_customer=False, + is_supplier=True) + + def test_company_model(self): + c = Company.objects.get(pk=1) + self.assertEqual(c.name, 'ABC Co.') + self.assertEqual(c.get_absolute_url(), '/company/1/') \ No newline at end of file